Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. class Customer extends Model
  2. {
  3. protected $table = 'customers';
  4.  
  5. public function contracts()
  6. {
  7. return $this->hasMany('AppContract');
  8. }
  9.  
  10. class Contract extends Model
  11. {
  12. public function customer()
  13. {
  14. return $this->belongsTo('AppCustomer');
  15. }
  16. }
  17.  
  18. $customers = Customer::with(['contracts' => function($query)
  19. {
  20. $query->where('data_end','>=','2017-07-01')
  21. ->where('data_end','<=','2017-07-31')
  22. ->where('typ','=','U') ;
  23. }
  24. ])->paginate(10);
  25.  
  26. "Customer 1"
  27. "Customer 2"
  28. "Customer 3"
  29. *"Contract 1"
  30. *"Contract 2"
  31. *"Contract 3"
  32. "Customer 4"
  33. *"Contract 1"
  34. *"Contract 2"
  35. *"Contract 3"
  36. "Customer 4"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement