changes 0230092025
This commit is contained in:
@@ -89,6 +89,27 @@
|
||||
})
|
||||
->get();
|
||||
|
||||
// Also search by contract reference and include affiliated cases ("Primeri")
|
||||
$limit = (int) ($request->input('limit') ?? 8);
|
||||
$query = trim((string) $request->input('query'));
|
||||
if ($query !== '') {
|
||||
$contractCases = \App\Models\Contract::query()
|
||||
->join('client_cases', 'contracts.client_case_id', '=', 'client_cases.id')
|
||||
->join('person', 'client_cases.person_id', '=', 'person.id')
|
||||
// portable case-insensitive match across drivers
|
||||
->whereRaw('LOWER(contracts.reference) LIKE ?', ['%'.mb_strtolower($query).'%'])
|
||||
->select('person.*', 'client_cases.uuid as case_uuid')
|
||||
->limit($limit)
|
||||
->get();
|
||||
|
||||
// Merge and de-duplicate by case uuid
|
||||
$clientCases = $clientCases
|
||||
->concat($contractCases)
|
||||
->unique('case_uuid')
|
||||
->values()
|
||||
->take($limit);
|
||||
}
|
||||
|
||||
return [
|
||||
'clients' => $clients,
|
||||
'client_cases' => $clientCases,
|
||||
|
||||
Reference in New Issue
Block a user