<?php
namespace App\Models\Master;

use App\Models\BaseModel;

class MasterControlsModel extends BaseModel {
    protected $table = 'master_controls';
    protected $primaryKey = 'control_id';
    protected $allowedFields = [
        'dept_id',
        'control_name',
        'lot',
        'producer',
        'exp_date',
        'created_at',
        'updated_at',
        'deleted_at'
    ];
    protected $useTimestamps = true;
    protected $useSoftDeletes = true;

    public function search($keyword = null) {
        if ($keyword) {
            return $this->groupStart()
                ->like('control_name', $keyword)
                ->orLike('lot', $keyword)
                ->groupEnd()
                ->findAll();
        }
        return $this->findAll();
    }
}
