From 451522e6cf6fc7fe566ca9bbb175e3ed2c5c8980 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 22 Oct 2022 19:55:43 -0400 Subject: [PATCH] Replace task repo too --- .../Repository/TaskRepositoryInterface.php | 20 --------- .../Client/Servers/ScheduleTaskController.php | 11 +++-- app/Providers/RepositoryServiceProvider.php | 3 -- app/Repositories/Eloquent/TaskRepository.php | 44 ------------------- 4 files changed, 5 insertions(+), 73 deletions(-) delete mode 100644 app/Contracts/Repository/TaskRepositoryInterface.php delete mode 100644 app/Repositories/Eloquent/TaskRepository.php diff --git a/app/Contracts/Repository/TaskRepositoryInterface.php b/app/Contracts/Repository/TaskRepositoryInterface.php deleted file mode 100644 index 0cd980d21..000000000 --- a/app/Contracts/Repository/TaskRepositoryInterface.php +++ /dev/null @@ -1,20 +0,0 @@ -tasks()->orderByDesc('sequence_id')->first(); - /** @var \Pterodactyl\Models\Task $task */ - $task = $this->repository->create([ + /** @var Task $task */ + $task = Task::query()->create([ 'schedule_id' => $schedule->id, 'sequence_id' => ($lastTask->sequence_id ?? 0) + 1, 'action' => $request->input('action'), @@ -84,7 +83,7 @@ class ScheduleTaskController extends ClientApiController throw new HttpForbiddenException("A backup task cannot be created when the server's backup limit is set to 0."); } - $this->repository->update($task->id, [ + Task::query()->update([ 'action' => $request->input('action'), 'payload' => $request->input('payload') ?? '', 'time_offset' => $request->input('time_offset'), diff --git a/app/Providers/RepositoryServiceProvider.php b/app/Providers/RepositoryServiceProvider.php index 383ccc505..9cc332f29 100644 --- a/app/Providers/RepositoryServiceProvider.php +++ b/app/Providers/RepositoryServiceProvider.php @@ -6,7 +6,6 @@ use Illuminate\Support\ServiceProvider; use Pterodactyl\Repositories\Eloquent\EggRepository; use Pterodactyl\Repositories\Eloquent\NestRepository; use Pterodactyl\Repositories\Eloquent\NodeRepository; -use Pterodactyl\Repositories\Eloquent\TaskRepository; use Pterodactyl\Repositories\Eloquent\UserRepository; use Pterodactyl\Repositories\Eloquent\ApiKeyRepository; use Pterodactyl\Repositories\Eloquent\ServerRepository; @@ -20,7 +19,6 @@ use Pterodactyl\Contracts\Repository\EggRepositoryInterface; use Pterodactyl\Repositories\Eloquent\EggVariableRepository; use Pterodactyl\Contracts\Repository\NestRepositoryInterface; use Pterodactyl\Contracts\Repository\NodeRepositoryInterface; -use Pterodactyl\Contracts\Repository\TaskRepositoryInterface; use Pterodactyl\Contracts\Repository\UserRepositoryInterface; use Pterodactyl\Repositories\Eloquent\DatabaseHostRepository; use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface; @@ -58,7 +56,6 @@ class RepositoryServiceProvider extends ServiceProvider $this->app->bind(SessionRepositoryInterface::class, SessionRepository::class); $this->app->bind(SettingsRepositoryInterface::class, SettingsRepository::class); $this->app->bind(SubuserRepositoryInterface::class, SubuserRepository::class); - $this->app->bind(TaskRepositoryInterface::class, TaskRepository::class); $this->app->bind(UserRepositoryInterface::class, UserRepository::class); } } diff --git a/app/Repositories/Eloquent/TaskRepository.php b/app/Repositories/Eloquent/TaskRepository.php deleted file mode 100644 index 942c54d47..000000000 --- a/app/Repositories/Eloquent/TaskRepository.php +++ /dev/null @@ -1,44 +0,0 @@ -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()); - } -}