Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. public function hotels(){
  2. // where booking is the name of the pivot table
  3. return $this -> belongsToMany('Hotel','booking')
  4. ->pivot('column in booking','column in booking');
  5.  
  6. }
  7.  
  8. public function users(){
  9. // where booking is the name of the pivot table
  10. return $this -> belongsToMany('User','booking')
  11. ->pivot('column in booking','column in booking');
  12. }
  13.  
  14. $hotels = User::with('hotels') -> get();
  15. $users = Hotel::with('users') -> get();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement