SHARE
TWEET

Untitled

a guest Feb 17th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class User {
  2.     public function companies()
  3.     {
  4.         return $this->hasMany(AppCompanyEmployee::class)
  5.     }
  6. }
  7.  
  8. class Employee {
  9.  
  10. }
  11.  
  12. class Company {
  13.  
  14. }
  15.  
  16. class CompanyEmployee {
  17.  
  18. }
  19.  
  20. class Vacancy {
  21.     public function scopeMine($query)
  22.     {
  23.         $my_companies = auth()
  24.             ->user()
  25.             ->companies()
  26.             ->select('company_id')
  27.             ->pluck('company_id')
  28.             ->get()
  29.             ->toArray();
  30.  
  31.         return $query->whereIn('company_id', $my_companies);
  32.     }
  33. }
  34.    
  35. class VacancyController {
  36.     public function index()
  37.     {
  38.         return AppVacancy::mine()->get();
  39.     }
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top