public function updateBan($id, $ban) { if (!($model = $this->findById($id))) { throw new \Exception("Contractor not found", 1); return; } if (!($user = $model->user)) { throw new \Exception("User not found", 1); return; } if (!($throttle = \User::findThrottlerByUserId($user->id)) || !$user->hasAccess('contractor')) { throw new \Exception("User is not contractor", 1); return; } if ($ban === 'true') { $throttle->ban(); } else { $throttle->unban(); if ($throttle->isSuspended()) { $throttle->unsuspend(); } } return true; }