<?php
namespace App\Models\Qc;

use App\Models\BaseModel;

class ResultCommentsModel extends BaseModel {
    protected $table = 'result_comments';
    protected $primaryKey = 'result_comment_id';
    protected $allowedFields = [
        'control_id',
        'test_id',
        'comment_month',
        'com_text',
        'created_at',
        'updated_at',
        'deleted_at'
    ];
    protected $useTimestamps = true;
    protected $useSoftDeletes = true;

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