*/ class CategoryRepository extends BaseRepository implements CategoryRepositoryInterface { public function __construct(Category $model) { parent::__construct($model); } public function findBySlug(string $slug): ?Category { return $this->model->newQuery()->with('menuCourses')->where('slug', $slug)->first(); } /** * @param array $filters * @return LengthAwarePaginator */ public function paginate(array $filters = [], int $perPage = 15): LengthAwarePaginator { $query = $this->model->newQuery()->with('menuCourses'); if (! empty($filters['search'])) { $query->where('label', 'like', '%'.$filters['search'].'%'); } return $query->latest()->paginate($perPage); } }