Role.php 910 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Traits\ModelTimeFormat;
  5. use App\Traits\ModelLogChanging;
  6. class Role extends Model
  7. {
  8. use ModelLogChanging;
  9. use ModelTimeFormat;
  10. protected $fillable = ['name'];
  11. function users(){
  12. return $this->belongsToMany('App\User','user_role','id_role','id_user');
  13. }
  14. function authorities(){
  15. return $this->belongsToMany('App\Authority','authority_role','id_role','id_authority');
  16. }
  17. public function owners()
  18. { //货主
  19. return $this->belongsToMany(Owner::class);
  20. }
  21. public function userWorkGroups()
  22. { //工作组
  23. return $this->belongsToMany(UserWorkgroup::class,"role_user_work_group","role_id","user_work_group_id");
  24. }
  25. function laborCompanies(){
  26. return $this->belongsToMany('App\LaborCompany','role_labor_company','role_id','labor_company_id');
  27. }
  28. }