How to display room rates using mysql query?
I have 2 tables, namely the room table and the rental rate table, I want to display the rental rates for each room.
How to call it with mysql query ? i have tried using grouping, join. But it didn't work. Please help
CodePudding user response:
In your Room model add this relationship:
public function rates()
{
return $this->hasMany(RentalRate::class);
}
In Controller call:
$rooms = Room::with('rates')->get();
Read more about Laravel Relationships