ResetPasswordForm.php 918 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Admin\Actions\Form;
  3. use App\Models\Account;
  4. use Dcat\Admin\Contracts\LazyRenderable;
  5. use Dcat\Admin\Traits\LazyWidget;
  6. use Dcat\Admin\Widgets\Form;
  7. class ResetPasswordForm extends Form implements LazyRenderable
  8. {
  9. use LazyWidget;
  10. //弹窗表单
  11. public function form()
  12. {
  13. $id = isset($this->payload['id']) ? $this->payload['id'] : 0;
  14. $this->hidden('id')->value($id);
  15. $this->password('password', '密码')->required();
  16. }
  17. //点击表单处理
  18. public function handle(array $input)
  19. {
  20. try {
  21. $account = Account::find($input['id']);
  22. $account->password = \Hash::make($input['password']);;
  23. $account->save();
  24. } catch (\Exception $exception) {
  25. return $this->response()->error($exception->getMessage());
  26. }
  27. return $this->response()->success('success')->refresh();
  28. }
  29. }