belongsToMany('App\Models\Updat\UpdatPermission', 'updat_role_permissions', 'role_id', 'permission_id'); } public function users() { return $this->hasMany('App\User', 'role_id'); } protected static function booted(): void { if (auth()->user()) { static::addGlobalScope('organisation-filter', function (Builder $builder) { $builder->where(function ($q) { $q->where('organisation_id', auth()->user()->organisation_id) ->orWhere('organisation_id', null); }); }); } static::updating(function ($model) { Log::info("Updating model: " . get_class($model) . " | ID: " . $model->id); cache()->flush(); }); static::deleting(function ($model) { Log::info("Deleting model: " . get_class($model) . " | ID: " . $model->id); }); } }