I need to get all Prestations where status is 'Disponible', and the Items associate Users first_name and last_name between three tables. I tried this :
$prestations = Prestation::whereHas('item', function($query) use ($available) {
$query->where('status', $available);
})
->join('items', 'items.prestation_id', '=', 'prestations.id')
->join('users', 'users.id', '=', 'items.user_id')
->select('prestations.*',
'users.first_name as firstname',
'users.last_name as lastname'
)
->get();
return $prestations;
It's be Okay to get all Prestations where the Item Status is 'Disponible' but my select don't return me the datas what i want, i get only one "_id" for each "Prestation".
Thank you for your help.