andWhere(['category_id' => $id])->exists(); } public function save(BlogPost $post): void { if (!$post->save()) { throw new \RuntimeException('Saving error.'); } } public function remove(BlogPost $post): void { if (!$post->delete()) { throw new \RuntimeException('Removing error.'); } } }