Skip to content

Commit

Permalink
add search in relationship feature
Browse files Browse the repository at this point in the history
  • Loading branch information
reziamini committed Jan 5, 2021
1 parent 321373c commit eb53fcc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Commands/stub/read.stub
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ class Read extends Component
$array = (array) config('easy_panel.crud.{{ model }}.search');
$data->where(function (Builder $query) use ($array){
foreach ($array as $item) {
$query->orWhere($item, 'like', '%'.$this->search.'%');
if(!is_array($item)) {
$query->orWhere($item, 'like', '%' . $this->search . '%');
} else {
$query->orWhereHas(array_key_first($item), function (Builder $query) use ($item) {
$query->where($item[array_key_first($item)], 'like', '%' . $this->search . '%');
});
}
}
});
}
Expand Down

0 comments on commit eb53fcc

Please sign in to comment.