Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function hotels(){
- // where booking is the name of the pivot table
- return $this -> belongsToMany('Hotel','booking')
- ->pivot('column in booking','column in booking');
- }
- public function users(){
- // where booking is the name of the pivot table
- return $this -> belongsToMany('User','booking')
- ->pivot('column in booking','column in booking');
- }
- $hotels = User::with('hotels') -> get();
- $users = Hotel::with('users') -> get();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement