| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace App\Module\User\AdminControllers\Actions;
- use App\Module\User\Services\UserService;
- use Dcat\Admin\Grid\RowAction;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Validator;
- /**
- * 修改用户密码操作
- */
- class ChangePasswordAction extends RowAction
- {
- /**
- * 操作标题
- *
- * @var string
- */
- protected $title = '<i class="fa fa-key"></i> 重置密码';
- /**
- * 处理请求
- *
- * @param Request $request
- * @return \Dcat\Admin\Actions\Response
- */
- public function handle(Request $request)
- {
- // 获取当前行的用户ID
- $userId = $this->getKey();
- // 调用服务修改密码
- $result = UserService::resetPassword($userId, '123456');
- if ($result === true) {
- return $this->response()->success('密码修改成功')->refresh();
- }
- return $this->response()->error('密码修改失败: ' . $result);
- }
- /**
- * 确认信息
- *
- * @return array|string|void
- */
- public function confirm()
- {
- return ['确定要重置该用户的密码吗?', '此操作将重置用户的登录密码为 123456 '];
- }
- }
|