33 lines
720 B
PHP
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);
|
|
}
|
|
} |