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