UserAuth.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace App\Admin\Actions\Users;
  3. use Dcat\Admin\Grid\RowAction;
  4. use Dcat\Admin\Widgets\Modal;
  5. use Illuminate\Http\Request;
  6. class UserAuth extends RowAction
  7. {
  8. protected $title;
  9. protected $model;
  10. public function __construct(string $model = null)
  11. {
  12. $this->model = $model;
  13. $this->title = '<i class="feather icon-user-check"></i> '.trans('user.fields.user_authentication');
  14. }
  15. /**
  16. * 设置确认弹窗信息,如果返回空值,则不会弹出弹窗
  17. *
  18. * 允许返回字符串或数组类型
  19. *
  20. * @return array|string|void
  21. */
  22. public function confirm()
  23. {
  24. // return [
  25. // "确定认证吗?"
  26. // ];
  27. }
  28. /**
  29. * 处理请求
  30. *
  31. * @param Request $request
  32. *
  33. * @return \Dcat\Admin\Actions\Response
  34. */
  35. public function handle(Request $request)
  36. {
  37. // // 获取当前行ID
  38. // $id = $this->getKey();
  39. //
  40. // // 获取 parameters 方法传递的参数
  41. // $model = $request->get('model');
  42. // $apply = $model::find($id);
  43. // $apply->is_auth=1;
  44. // $apply->save();
  45. // // 返回响应结果并刷新页面
  46. // return $this->response()->success("操作成功")->refresh();
  47. }
  48. /**
  49. * 设置要POST到接口的数据
  50. *
  51. * @return array
  52. */
  53. public function parameters()
  54. {
  55. return [
  56. // 发送当前行 username 字段数据到接口
  57. 'status' => $this->row->is_auth,
  58. // 把模型类名传递到接口
  59. 'model' => $this->model,
  60. ];
  61. }
  62. public function render()
  63. {
  64. $form = UserAuthForm::make()->payload(['id'=>$this->getKey()]);
  65. return Modal::make()
  66. ->lg()
  67. ->title($this->title)
  68. ->body($form)
  69. ->button($this->title);
  70. }
  71. }