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