can('dcat.admin.users.edit_phone'); } /** * Handle the form request. * * @param array $input * * @return mixed */ public function handle(array $input) { $id = $this->payload['id'] ?? 0; $user = User::findOrFail($id); try { DB::beginTransaction(); $user->update($input); DB::commit(); } catch (Throwable $th) { DB::rollBack(); report($th); return $this->response()->error('操作失败:'.$th->getMessage()); } return $this->response() ->success(__('admin.update_succeeded')) ->refresh(); } /** * Build a form here. */ public function form() { $id = $this->payload['id'] ?? 0; $user = User::findOrFail($id); $this->text('old_phone', '旧手机号')->value($user->phone)->disable(); $this->mobile('phone')->rules('unique:users,phone', ['unique'=>'该手机号已存在'])->required(); } }