Files
silaras-rssa/app/Controllers/Pegawai.php
T
2026-05-13 08:55:17 +07:00

33 lines
720 B
PHP

<?php
namespace App\Controllers;
use App\Models\PegawaiModel;
class Pegawai extends BaseController
{
public function search()
{
$term = $this->request->getGet('q');
$model = new PegawaiModel();
$data = $model
->groupStart()
->like('nama', $term)
->orLike('jabatan', $term)
->groupEnd()
->orderBy('nama', 'ASC')
->findAll(10);
$result = [];
foreach ($data as $row) {
$result[] = [
'id' => $row['id'],
'text' => $row['nama'] . ' - ' . $row['jabatan']
];
}
return $this->response->setJSON($result);
}
}