We have company and their users. We want to get all booking list with users of a company.
Please suggest how can we solve this issue.
Let's something like this
$booking=Booking::with('users')->where()
In where like
users.company_id=$company_id
I think you need this:
$company_id = 1;
$booking=Booking::with('users' => function ($query) use ($company_id) {
$query->where('company_id', $company_id);
}])->get();
It's in Documentation, the name of this is "Constraining Eager Loads"