*/ class ScheduleRepository extends BaseRepository implements ScheduleRepositoryInterface { public function __construct(CourseSchedule $model) { parent::__construct($model); } /** * @param array $filters * @return LengthAwarePaginator */ public function paginate(array $filters = [], int $perPage = 15): LengthAwarePaginator { $query = $this->model->newQuery()->with('course.category'); if (! empty($filters['course_id'])) { $query->where('course_id', $filters['course_id']); } return $query->orderBy('start_date')->paginate($perPage); } /** * @return Collection */ public function upcoming(int $limit = 20): Collection { return $this->model->newQuery() ->with('course.category') ->where('start_date', '>=', now()) ->orderBy('start_date') ->limit($limit) ->get(); } }