UserPaycodeUpdateAction.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace App\Admin\Actions\Grid\User;
  3. use App\Admin\Forms\User\UserPaycodeForm;
  4. use Dcat\Admin\Actions\Response;
  5. use Dcat\Admin\Grid\RowAction;
  6. use Dcat\Admin\Traits\HasPermissions;
  7. use Dcat\Admin\Widgets\Modal;
  8. use Illuminate\Contracts\Auth\Authenticatable;
  9. use Illuminate\Database\Eloquent\Model;
  10. use Illuminate\Http\Request;
  11. class UserPaycodeUpdateAction extends RowAction
  12. {
  13. /**
  14. * @return string
  15. */
  16. protected $title = '支付密码';
  17. public function render()
  18. {
  19. $form = UserPaycodeForm::make()->payload(["id"=>$this->getKey()]);
  20. return Modal::make()
  21. ->lg()
  22. ->title($this->title)
  23. ->body($form)
  24. // 因为此处使用了表单异步加载功能,所以一定要用 onLoad 方法
  25. // 如果是非异步方式加载表单,则需要改成 onShow 方法
  26. ->button($this->title);
  27. }
  28. /**
  29. * Handle the action request.
  30. *
  31. * @param Request $request
  32. *
  33. * @return Response
  34. */
  35. public function handle(Request $request)
  36. {
  37. // dump($this->getKey());
  38. return $this->response()
  39. ->success('Processed successfully: '.$this->getKey())
  40. ->redirect('/');
  41. }
  42. /**
  43. * @return string|array|void
  44. */
  45. public function confirm()
  46. {
  47. // return ['Confirm?', 'contents'];
  48. }
  49. /**
  50. * @param Model|Authenticatable|HasPermissions|null $user
  51. *
  52. * @return bool
  53. */
  54. protected function authorize($user): bool
  55. {
  56. return true;
  57. }
  58. /**
  59. * @return array
  60. */
  61. protected function parameters()
  62. {
  63. return [];
  64. }
  65. }