| 12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- use App\Traits\ModelTimeFormat;
- use App\Traits\ModelLogChanging;
- class Role extends Model
- {
- use ModelLogChanging;
- use ModelTimeFormat;
- protected $fillable = ['name'];
- function users(){
- return $this->belongsToMany('App\User','user_role','id_role','id_user');
- }
- function authorities(){
- return $this->belongsToMany('App\Authority','authority_role','id_role','id_authority');
- }
- public function owners()
- { //货主
- return $this->belongsToMany(Owner::class);
- }
- public function userWorkGroups()
- { //工作组
- return $this->belongsToMany(UserWorkgroup::class,"role_user_work_group","role_id","user_work_group_id");
- }
- function laborCompanies(){
- return $this->belongsToMany('App\LaborCompany','role_labor_company','role_id','labor_company_id');
- }
- }
|