-
app/Contracts/Repository/TaskRepositoryInterface.php
Open in GitHubuse Pterodactyl\Models\Task; interface TaskRepositoryInterface extends RepositoryInterface { public function getTaskForJobProcess(int $id): Task; public function getNextTask(int $schedule, int $index); }
-
app/Repositories/Eloquent/TaskRepository.php
Open in GitHubuse Pterodactyl\Models\Task; use Illuminate\Database\Eloquent\ModelNotFoundException; use Pterodactyl\Contracts\Repository\TaskRepositoryInterface; use Pterodactyl\Exceptions\Repository\RecordNotFoundException; class TaskRepository extends EloquentRepository implements TaskRepositoryInterface { public function model() { return Task::class; } public function getTaskForJobProcess(int $id): Task { try { return $this->getBuilder()->with('server.user', 'schedule')->findOrFail($id, $this->getColumns()); } catch (ModelNotFoundException $exception) { throw new RecordNotFoundException(); } } public function getNextTask(int $schedule, int $index) { return $this->getBuilder()->where('schedule_id', '=', $schedule) ->where('sequence_id', '=', $index + 1) ->first($this->getColumns()); } }
-
app/Contracts/Repository/RepositoryInterface.php
Open in GitHubnamespace Pterodactyl\Contracts\Repository; use Illuminate\Support\Collection; use Illuminate\Contracts\Pagination\LengthAwarePaginator; interface RepositoryInterface { /** * Return an identifier or Model object to be used by the repository. * * @return string|\Closure|object */ public function model(); /** * Return the model being used for this repository instance. * * @return mixed */ public function getModel(); /** * Returns an instance of a query builder. * * @return mixed */ public function getBuilder(); // ... other methods }