getModel(); $filter = $this->getModelFilter(); $query = $this->query(); if($this->withRelationships){ $query->with($this->withRelationships); } if ($filter) { $query->filter(request()->input(), $filter); } return $query->sort(); } public function update($primaryKey, $data): bool { $cid = data_get($data, 'category_id'); if ($cid && $category = ArticleCategory::find($cid)) { $data['category_path'] = $category->path . $category->id . '-'; } return parent::update($primaryKey, $data); } public function store($data): bool { $cid = data_get($data, 'category_id'); if ($cid && $category = ArticleCategory::find($cid)) { $data['category_path'] = $category->path . $category->id . '-'; } return parent::store($data); } public function delete(string $ids): mixed { $id = explode(',', $ids); // 解除关联的公告 AdminNotice::whereIn('article_id', $id)->update(['article_id' => null]); return $this->query()->whereIn($this->primaryKey(), explode(',', $ids))->delete(); } }