fix 4
This commit is contained in:
parent
e804d6f4d5
commit
1620136d7d
|
|
@ -41,10 +41,9 @@ public function toSearchableArray(): array
|
|||
'phones' => $this->person->phones
|
||||
];*/
|
||||
|
||||
$this->loadMissing('person');
|
||||
$array = $this->toArray();
|
||||
|
||||
$array['person'] = $this->person ? $this->person->toArray() : [];
|
||||
$array['person'] = $this->person ? $this->person->only('full_name') : null;
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,10 +34,9 @@ protected function makeAllSearchableUsing(Builder $query): Builder
|
|||
|
||||
public function toSearchableArray(): array
|
||||
{
|
||||
$this->loadMissing('person');
|
||||
$array = $this->toArray();
|
||||
|
||||
$array['person'] = $this->person ? $this->person->toArray() : [];
|
||||
$array['person'] = $this->person ? $this->person->only('full_name') : null;
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,17 +44,21 @@
|
|||
Route::get('search', function(Request $request) {
|
||||
|
||||
if( !empty($request->input('query')) ) {
|
||||
$clients = App\Models\Client::search($request->input('query'))
|
||||
/*$clients = App\Models\Client::search($request->input('query'))
|
||||
->query(function($q) use($request) {
|
||||
$q->with('person')->limit($request->input('limit'));
|
||||
})
|
||||
->get();
|
||||
->get();*/
|
||||
$clients = App\Models\Client::search($request->input('query'))
|
||||
->get()
|
||||
->load('person:id,full_name')
|
||||
->take(5);
|
||||
|
||||
$clientCases = App\Models\ClientCase::search($request->input('query'))
|
||||
->query(function($q) use($request) {
|
||||
$q->with('person')->limit($request->input('limit'));
|
||||
})
|
||||
->get();
|
||||
->get()
|
||||
->load('person:id,full_name')
|
||||
->take(5);
|
||||
|
||||
|
||||
return [
|
||||
'clients' => $clients,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user