How do I use join with Eloquent taking in consideration the following table structure:
I have a properies table
--------------------- ID | Name -
Define the relationship on your Property model class:
hasMany(Room::class); } }
$properties = Property::withCount(['rooms'])->get();
This will add a rooms_count to the result.