Guest User

Untitled

a guest
Oct 17th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. class Coupon extends Eloquent {
  2.  
  3. public function cities(){
  4.  
  5. return $this->belongsToMany('City', 'coupon_cities', 'coupon_id', 'city_id');
  6. }
  7. }
  8.  
  9. Coupon::with('cities')
  10.  
  11. $coupon = Coupon->first();
  12. $coupon->cities()->get([your columns here]);
  13.  
  14. Coupon::with(['cities' => function ($q)
  15. {
  16. $q->select('column', 'column2' ...);
  17. }
Add Comment
Please, Sign In to add comment