add contact param

This commit is contained in:
mahdahar 2025-09-26 16:41:55 +07:00
parent 38bb2e04d3
commit ba9e386b4d
2 changed files with 9 additions and 3 deletions

View File

@ -19,8 +19,11 @@ class Contact extends Controller {
}
public function index() {
$ContactName = $this->request->getVar('ContactName');
$Specialty = $this->request->getVar('Specialty');
$model = new ContactModel();
$rows = $model->getContacts();
$rows = $model->getContacts($ContactName, $Specialty);
//$rows = $model->getContacts();
if (empty($rows)) {
return $this->respond([

View File

@ -18,8 +18,11 @@ class ContactModel extends Model {
return $rows;
}
public function getContacts() {
$rows = $this->select("ContactID, NameFirst, NameLast, Title, Initial, Specialty")->get()->getResultArray();
public function getContacts($ContactName, $Specialty) {
$sql = $this->select("ContactID, NameFirst, NameLast, Title, Initial, Specialty");
if($ContactName !='') { $sql->like('NameFirst',$ContactName,'both')->orLike('NameLast',$ContactName,'both'); }
if($Specialty != '') { $sql->like('Specialty',$Specialty); }
$rows = $sql->get()->getResultArray();
return $rows;
}