Replace task repo too
This commit is contained in:
parent
e0f5856589
commit
451522e6cf
4 changed files with 5 additions and 73 deletions
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Repositories\Eloquent;
|
||||
|
||||
use Pterodactyl\Models\Task;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Pterodactyl\Contracts\Repository\TaskRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
|
||||
|
||||
class TaskRepository extends EloquentRepository implements TaskRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Return the model backing this repository.
|
||||
*/
|
||||
public function model(): string
|
||||
{
|
||||
return Task::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a task and the server relationship for that task.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getTaskForJobProcess(int $id): Task
|
||||
{
|
||||
try {
|
||||
return $this->getBuilder()->with('server.user', 'schedule')->findOrFail($id, $this->getColumns());
|
||||
} catch (ModelNotFoundException) {
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next task in a schedule.
|
||||
*/
|
||||
public function getNextTask(int $schedule, int $index): ?Task
|
||||
{
|
||||
return $this->getBuilder()->where('schedule_id', '=', $schedule)
|
||||
->orderBy('sequence_id')
|
||||
->where('sequence_id', '>', $index)
|
||||
->first($this->getColumns());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue