Guest User

Untitled

a guest
Nov 18th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. Profile Model:
  2. id
  3. name
  4.  
  5. Job Model:
  6. id
  7. client_id
  8. description
  9.  
  10. Offer Model:
  11. id
  12. job_id
  13. price
  14.  
  15. public function offers()
  16. {
  17. return $this->hasManyThrough(Offer::class, Job::class, 'client_id', 'job_id', 'client_id', 'id');
  18. }
  19.  
  20. >>> $p = Profile::find('H5JJ44HLK545SKDJ');
  21. => AppProfile {#1018
  22. id: "H5JJ44HLK545SKDJ",
  23. password: "$2y$10$4wvysfaqc.vwnabKsHOnnOpXJlIp.kTLgOD2jViOTVH9JAXj4qxtO",
  24. name: "TestName",
  25. }
  26. >>> $p->offers()->toSql();
  27. => "select * from `offers` inner join `jobs` on `jobs`.`id` = `offers`.`job_id` where `jobs`.`client_id` is null"
Add Comment
Please, Sign In to add comment