relationship

How to add additional column relationship in pivot table in Laravel

冷暖自知 提交于 2020-12-13 10:46:41
问题 Version: Laravel 5.4 I have 3 Models Model: Employee protected $fillable = ['name']; public function emails(){ return $this->belongsToMany('App\Email')->using('App\EmailEmployee'); } Model: Email protected $fillable = ['username']; public function employees(){ return $this->belongsToMany('App\Employee')->using('App\EmailEmployee'); } Every Employee has many email access and emails allocates to many employees. But I have another column in email_employee table email_id (emails table) employee

How to add additional column relationship in pivot table in Laravel

 ̄綄美尐妖づ 提交于 2020-12-13 10:46:38
问题 Version: Laravel 5.4 I have 3 Models Model: Employee protected $fillable = ['name']; public function emails(){ return $this->belongsToMany('App\Email')->using('App\EmailEmployee'); } Model: Email protected $fillable = ['username']; public function employees(){ return $this->belongsToMany('App\Employee')->using('App\EmailEmployee'); } Every Employee has many email access and emails allocates to many employees. But I have another column in email_employee table email_id (emails table) employee