action = $action; //$action:1=通过;2=拒绝 $this->title = $action == 1 ? '通过' : '拒绝'; } protected function html() { $class = $this->action == 1 ? 'btn btn-sm btn-success' : 'btn btn-sm btn-danger'; $this->appendHtmlAttribute('class', $class); $this->defaultHtmlAttribute('href', 'javascript:;'); return "formatHtmlAttributes()}>{$this->title}"; } public function handle(Request $request) { try { $user = IndustryProduct::find($this->getKey()); $user->status = $request->action == 1 ? ProductStatus::ON_SALE : ProductStatus::REFUSE; $user->save(); return $this->response()->success("审核成功")->refresh(); } catch (\Exception $e) { return $this->response()->error($e->getMessage()); } } public function confirm() { return ['确定要'.$this->title.'该产品吗?', '']; } public function parameters() { return ['action' => $this->action]; } }