belongsTo('App\Permission'); } public function role() { return $this->belongsTo('App\Role'); } public function scopeByPermission($query, $id) { return $query->where('permission_id', $id); } public function scopeByRole($query, $id) { return $query->where('role_id', $id); } }