update deploy
This commit is contained in:
47
app/Repositories/Eloquent/ScheduleRepository.php
Normal file
47
app/Repositories/Eloquent/ScheduleRepository.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Eloquent;
|
||||
|
||||
use App\Models\CourseSchedule;
|
||||
use App\Repositories\Contracts\ScheduleRepositoryInterface;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* @extends BaseRepository<CourseSchedule>
|
||||
*/
|
||||
class ScheduleRepository extends BaseRepository implements ScheduleRepositoryInterface
|
||||
{
|
||||
public function __construct(CourseSchedule $model)
|
||||
{
|
||||
parent::__construct($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $filters
|
||||
* @return LengthAwarePaginator<int, CourseSchedule>
|
||||
*/
|
||||
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<int, CourseSchedule>
|
||||
*/
|
||||
public function upcoming(int $limit = 20): Collection
|
||||
{
|
||||
return $this->model->newQuery()
|
||||
->with('course.category')
|
||||
->where('start_date', '>=', now())
|
||||
->orderBy('start_date')
|
||||
->limit($limit)
|
||||
->get();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user