nhance/app/Models/ThzMasterNotesModel.php

79 lines
2.1 KiB
PHP

<?php
namespace App\Models;
use CodeIgniter\Model;
class ThzMasterNotesModel extends Model
{
protected $table = 'thz_master_notes';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['thz_id','notes','notes_by','created_by','created_at'];
protected bool $allowEmptyInserts = false;
// Dates
protected $useTimestamps = false;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
// Validation
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
protected $cleanValidationRules = true;
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = [];
protected $afterInsert = [];
protected $beforeUpdate = [];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
public function conversationListForUserPerTicket($thz_id){
if(empty($thz_id)){
return false;
}
$sql = "SELECT
thz_master_notes.id,
thz_master_notes.thz_id,
thz_master_notes.notes,
thz_master_notes.notes_by,
thz_master_notes.created_by,
thz_master_notes.created_at
FROM
thz_master_notes
Join thz_master ON thz_master.thz_id = :thz_id:
WHERE
thz_master_notes.thz_id = :thz_id:
ORDER BY
thz_master_notes.created_at DESC
";
$binds = ["thz_id" => $thz_id ];
$result = $this->db->query($sql,$binds)->getResultArray() ;
return $result;
}
}