关闭'; /** * 判断是否允许显示此操作 * * @return bool */ public function allowed() { return $this->row->status === ACTIVITY_STATUS::ENDED; } /** * 处理请求 * * @param Request $request * @return mixed */ public function handle(Request $request) { try { $id = $this->getKey(); $activity = ActivityConfig::findOrFail($id); if ($activity->status !== ACTIVITY_STATUS::ENDED) { return $this->response()->error('只有已结束的活动才能关闭'); } $activity->status = ACTIVITY_STATUS::CLOSED; $activity->save(); // 触发活动状态变更事件 event(new \App\Module\Activity\Events\ActivityStatusChangedEvent( $activity->id, ACTIVITY_STATUS::ENDED, ACTIVITY_STATUS::CLOSED )); return $this->response() ->success("活动 [{$activity->name}] 已关闭") ->refresh(); } catch (\Exception $e) { return $this->response() ->error('操作失败: ' . $e->getMessage()); } } /** * 确认信息 * * @return array|string|void */ public function confirm() { return ['确定要关闭此活动吗?', '关闭后活动将完全不可见,用户无法查看活动信息']; } }