I made a searchScope in one model. This is working perfectly. But i need to make this search field for multiple models. When i search a string it must scan other tables. What i have done so far:
public function scopeSearch(Builder $query, $search)
{
$query->whereHas('translations', function ($q) use ($search) {
$q->where('value', 'like', '%' . $search . '%');
})
->orWhere('title', 'LIKE', '%' . $search . '%')
->orWhere('sub_body', 'like', '%' . $search . '%')
->orWhere('body', 'like', '%' . $search . '%');
}
Translation table has all other model's translated values. Thats good. Because i just want to add 2-3 extra models in this query. How can i do that? Thanks in advance.