Monday, February 27, 2017

How to observe foreign keys in Laravel 5?

I have this class
class User extends Model {
         public function roles() {
             return $this->belongsToMany('App\Models\SystemRole', 'app_system_role_users', 'user_id', 'role_id', 'id');
 } 
}

Table app_system_role_users contains map from user_id to role_id.
I want to save all changes to this table.
How can I observe foreign relationship? May be there are some events fired?


from Latest question asked on Laravel tag.


via Jackson J

Advertisement