dashboard = $dashboard; } /** * Execute the job. * * @return boolean */ public function handle() { $this->authorize(); $this->deleteRelationships($this->dashboard, ['widgets']); $this->dashboard->delete(); Artisan::call('cache:clear'); return true; } /** * Determine if this action is applicable. * * @return void */ public function authorize() { // Can't delete your last dashboard if (user()->dashboards()->enabled()->count() == 1) { $message = trans('dashboards.error.delete_last'); throw new \Exception($message); } // Check if user can access dashboard if (!$this->isUserDashboard($this->dashboard->id)) { $message = trans('dashboards.error.not_user_dashboard'); throw new \Exception($message); } } }