I need to find a group of collection WHERE the search is based on a record on a related model. To let you understand I need to get users with the company name that is LIKE my search input.
Here's what i've tried:
$users = App\User::with(['company' => function ($query) {
$query->where('company_name', 'like', '%'.$searchInput.'%');
}])->paginate(10);
To be honest I spent hours on this but with no luck. I'm using jenseggers/mongodb
on laravel 5.8.