0

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.

table room

table rental rate

How to call it with mysql query ? i have tried using grouping, join. But it didn't work. Please help

1 Answers1

0

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

Vüsal Hüseynli
  • 889
  • 1
  • 4
  • 16