'App\Policies\ModelPolicy', Course::class => CoursePolicy::class, ]; /** * Register any authentication / authorization services. * * @return void */ public function boot() { $this->registerPolicies(); Gate::define('add-permission', function ($user, $level, $division_id) { $user->loadMissing(['departments', 'faculties.departments']); return $user->is_admin || ($level === 1) && ($user->departments->contains($division_id) || $user->faculties->contains(function ($faculty, $key) use ($division_id) { return $faculty->departments->contains($division_id); })) || ($level === 2 && $user->faculties->contains($division_id)); }); // Gate::define('') } }