fixed error in search logic

This commit is contained in:
ilmedova 2023-03-24 12:39:35 +05:00
parent 0e51f1eb41
commit 1e24e8c787
1 changed files with 7 additions and 2 deletions

View File

@ -78,9 +78,14 @@ protected function setupListOperation()
'type' => 'profile_name',
'searchLogic' => function ($query, $column, $searchTerm) {
$query->whereHas('profile', function ($q) use ($column, $searchTerm) {
$q->where('name', 'like', '%'.$searchTerm.'%')
->orWhere('surname', 'like', '%'.$searchTerm.'%')
if($column->profile->type == "business"){
$q->where('name', 'like', '%'.$searchTerm.'%')
->orWhere('surname', 'like', '%'.$searchTerm.'%');
}
else{
$q->where('name', 'like', '%'.$searchTerm.'%')
->orWhere('short_name', 'like', '%'.$searchTerm.'%');
}
});
}
]);