canClick = $boolean; return $this; } /** * Handle the action request. * * @param Request $request * * @return Response */ public function handle(Request $request) { try { $user_id = $this->getKey(); DB::beginTransaction(); // 1、更新用户渠道商身份 User::find($user_id)->update(['is_place' => 1]); // 2、绑定用户渠道商角色 DB::table('agent_admin_role_users')->insertOrIgnore(['role_id' => 3, 'user_id' => $user_id]); DB::commit(); return $this->response() ->success('升级成功') ->refresh(); } catch (\Exception $e) { dd($e); info($e); return $this->response() ->error('升级失败'); } } /** * @return string|array|void */ public function confirm() { return ['升级渠道商?', '升级后该代理可在代理商后台查看用户盈亏数据']; } /** * @param Model|Authenticatable|HasPermissions|null $user * * @return bool */ protected function authorize($user): bool { return true; } /** * @return array */ protected function parameters() { return []; } public function html() { $this->appendHtmlAttribute('class', 'btn btn-outline-primary btn-sm btn-mini submit'); if (!$this->canClick) $this->appendHtmlAttribute('class', 'disabled'); return parent::html(); } }