| xqd
@@ -0,0 +1,82 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+namespace App\Admin\Actions\Users;
|
|
|
+
|
|
|
+
|
|
|
+use Dcat\Admin\Grid\RowAction;
|
|
|
+use Illuminate\Http\Request;
|
|
|
+
|
|
|
+class Report extends RowAction
|
|
|
+{
|
|
|
+
|
|
|
+ protected $model;
|
|
|
+
|
|
|
+ public function __construct(string $model = null)
|
|
|
+ {
|
|
|
+ $this->model = $model;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 返回字段标题
|
|
|
+ *
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function title()
|
|
|
+ {
|
|
|
+ return '标记处理';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置确认弹窗信息,如果返回空值,则不会弹出弹窗
|
|
|
+ *
|
|
|
+ * 允许返回字符串或数组类型
|
|
|
+ *
|
|
|
+ * @return array|string|void
|
|
|
+ */
|
|
|
+ public function confirm()
|
|
|
+ {
|
|
|
+ return [
|
|
|
+ // 确认弹窗 title
|
|
|
+ "确定标记已处理这行数据吗?"
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理请求
|
|
|
+ *
|
|
|
+ * @param Request $request
|
|
|
+ *
|
|
|
+ * @return \Dcat\Admin\Actions\Response
|
|
|
+ */
|
|
|
+ public function handle(Request $request)
|
|
|
+ {
|
|
|
+ // 获取当前行ID
|
|
|
+ $id = $this->getKey();
|
|
|
+
|
|
|
+ // 获取 parameters 方法传递的参数
|
|
|
+ $model = $request->get('model');
|
|
|
+ $apply = $model::find($id);
|
|
|
+ $apply->status=1;
|
|
|
+ $apply->save();
|
|
|
+ // 返回响应结果并刷新页面
|
|
|
+ return $this->response()->success("操作成功")->refresh();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置要POST到接口的数据
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function parameters()
|
|
|
+ {
|
|
|
+ return [
|
|
|
+ // 发送当前行 username 字段数据到接口
|
|
|
+ 'status' => $this->row->status,
|
|
|
+ // 把模型类名传递到接口
|
|
|
+ 'model' => $this->model,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+}
|