'=', 'is_hot' => '=', 'is_top' => '=', 'category_id' => '=', ]; protected array $quickSearchField = ['title']; #[GetRoute(authorize: 'query')] public function query(Request $request): JsonResponse { $params = $request->all(); $pageSize = $params['pageSize'] ?? 10; $query = ForumPostModel::query(); $data = $this->buildSearch($params, $query) ->paginate($pageSize) ->toArray(); return $this->success($data); } #[PostRoute(authorize: 'create')] public function create(ForumPostFormRequest $request): JsonResponse { ForumPostModel::create($request->validated()); return $this->success(); } #[PutRoute( route: '/{id}', authorize: 'update', where: ['id' => '[0-9]+'] )] public function update(int $id, ForumPostFormRequest $request): JsonResponse { $model = ForumPostModel::find($id); if (empty($model)) { return $this->error('帖子不存在'); } $model->update($request->validated()); return $this->success(); } #[DeleteRoute( route: '/{id}', authorize: 'delete', where: ['id' => '[0-9]+'] )] public function delete(int $id): JsonResponse { $model = ForumPostModel::find($id); if (empty($model)) { return $this->error('帖子不存在'); } $model->delete(); return $this->success(); } }