'=', 'category_id' => '=', ]; protected array $quickSearchField = ['name', 'contact_name', 'contact_mobile']; #[GetRoute(authorize: 'query')] public function query(Request $request): JsonResponse { $params = $request->all(); $pageSize = $params['pageSize'] ?? 10; $query = MerchantStoreModel::query(); $data = $this->buildSearch($params, $query) ->paginate($pageSize) ->toArray(); return $this->success($data); } #[PostRoute(authorize: 'create')] public function create(MerchantStoreFormRequest $request): JsonResponse { MerchantStoreModel::create($request->validated()); return $this->success(); } #[PutRoute( route: '/{id}', authorize: 'update', where: ['id' => '[0-9]+'] )] public function update(int $id, MerchantStoreFormRequest $request): JsonResponse { $model = MerchantStoreModel::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 = MerchantStoreModel::find($id); if (empty($model)) { return $this->error('商户不存在'); } $model->delete(); return $this->success(); } }