Path: blob/1.0-develop/app/Repositories/Eloquent/ScheduleRepository.php
7460 views
<?php12namespace Pterodactyl\Repositories\Eloquent;34use Pterodactyl\Models\Schedule;5use Illuminate\Support\Collection;6use Illuminate\Database\Eloquent\ModelNotFoundException;7use Pterodactyl\Exceptions\Repository\RecordNotFoundException;8use Pterodactyl\Contracts\Repository\ScheduleRepositoryInterface;910class ScheduleRepository extends EloquentRepository implements ScheduleRepositoryInterface11{12/**13* Return the model backing this repository.14*/15public function model(): string16{17return Schedule::class;18}1920/**21* Return all the schedules for a given server.22*/23public function findServerSchedules(int $server): Collection24{25return $this->getBuilder()->withCount('tasks')->where('server_id', '=', $server)->get($this->getColumns());26}2728/**29* Return a schedule model with all the associated tasks as a relationship.30*31* @throws RecordNotFoundException32*/33public function getScheduleWithTasks(int $schedule): Schedule34{35try {36return $this->getBuilder()->with('tasks')->findOrFail($schedule, $this->getColumns());37} catch (ModelNotFoundException) {38throw new RecordNotFoundException();39}40}41}424344