Path: blob/1.0-develop/app/Repositories/Eloquent/TaskRepository.php
7460 views
<?php12namespace Pterodactyl\Repositories\Eloquent;34use Pterodactyl\Models\Task;5use Illuminate\Database\Eloquent\ModelNotFoundException;6use Pterodactyl\Contracts\Repository\TaskRepositoryInterface;7use Pterodactyl\Exceptions\Repository\RecordNotFoundException;89class TaskRepository extends EloquentRepository implements TaskRepositoryInterface10{11/**12* Return the model backing this repository.13*/14public function model(): string15{16return Task::class;17}1819/**20* Get a task and the server relationship for that task.21*22* @throws RecordNotFoundException23*/24public function getTaskForJobProcess(int $id): Task25{26try {27return $this->getBuilder()->with('server.user', 'schedule')->findOrFail($id, $this->getColumns());28} catch (ModelNotFoundException) {29throw new RecordNotFoundException();30}31}3233/**34* Returns the next task in a schedule.35*/36public function getNextTask(int $schedule, int $index): ?Task37{38return $this->getBuilder()->where('schedule_id', '=', $schedule)39->orderBy('sequence_id')40->where('sequence_id', '>', $index)41->first($this->getColumns());42}43}444546