where('title', "%{$params['title']}%"); isset($params['status']) && filled($params['status']) && $category->where('status', $params['status']); $categoryPage = $category->paginate($params['pageSize'], [...$this->simpleColumn, ...$this->selectColumn, ...$this->appendColumn], 'page', $params['pageNo']); return ['list' => $categoryPage->items(), 'total' => $categoryPage->total()]; } public function createCategory(array $data) { $category = self::toModel($data, Category::class); return $category->create($category->getAttributes())->id; } public function getCategory(int $id) { return Category::query()->select([...$this->simpleColumn, ...$this->selectColumn])->find($id); } public function updateCategory(array $data, int $id): void { $category = self::toModel($data, Category::class); $category->where('id', $id)->update($category->getAttributes()); } public function deleteCategory(int $id) { $category = self::toModel(['id' => $id], Category::class); return $category->delete(); } public function getCategorySimpleList() { return Category::query()->where('status', Status::ENABLE)->select($this->simpleColumn)->get(); } }