Im trying to create new query with join statement.
My current query:
BookingMaster::with('user:id,name')->where('branch_id', $branch->id)->orderBy('id', 'desc')->get();
Here is my branch query with join but I dont know how to use that with('user:id,name')
DB::table('branch')
->join('business', 'branch.business_id', '=', 'business.id')
->join('branch_managers', 'branch.id', '=', 'branch_id')
->join('booking_master', 'branch.id', '=', 'branch_id')
->select('branch.id', 'branch.name', 'branch.address', 'branch.for_who', 'branch.start_time', 'branch.end_time', 'branch.icon', 'branch.is_featured', 'branch.status', 'booking_master.')
->where('branch_managers.user_id', Auth::id())
->get();
If I did like this in admin panel it showed all data what I need:
public function show(Branch $branch)
$booking = BookingMaster::with('user:id,name')->where('branch_id', $branch->id)->orderBy('id', 'desc')->get();
$review = Review::with('user:id,name')->where('branch_id', $branch->id)->orderBy('id', 'desc')->get();
$service = Category::with('service')->whereIn('id', $branch->category)->get();
$employee = EmployeeInfo::with('user:id,name,email')->whereIn('emp_id', $branch->employee)->get();
return view('salon.branch.show', compact('branch', 'booking', 'review', 'service', 'employee'));
}
But now for business panel where is Different roles like owner and manager. For owner I show all his branches and manager all assigned branches. at the moment if I change url ID it shows different business branches..
At the moment I think this show branches views all branches even these what is not assigned or created by user:
public function show(Branch $branch)