diff --git a/app/Contracts/Repository/ScheduleRepositoryInterface.php b/app/Contracts/Repository/ScheduleRepositoryInterface.php deleted file mode 100644 index fa9c18b41..000000000 --- a/app/Contracts/Repository/ScheduleRepositoryInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -repository->create([ + /** @var Schedule $model */ + $model = Schedule::query()->create([ 'server_id' => $server->id, 'name' => $request->input('name'), 'cron_day_of_week' => $request->input('day_of_week'), @@ -96,8 +96,8 @@ class ScheduleController extends ClientApiController /** * Updates a given schedule with the new data provided. * - * @throws \Pterodactyl\Exceptions\DisplayException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException + * @throws DisplayException + * @throws DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function update(UpdateScheduleRequest $request, Server $server, Schedule $schedule): array @@ -124,7 +124,7 @@ class ScheduleController extends ClientApiController $data['is_processing'] = false; } - $this->repository->update($schedule->id, $data); + $schedule->update($data); Activity::event('server:schedule.update') ->subject($schedule) @@ -156,7 +156,7 @@ class ScheduleController extends ClientApiController */ public function delete(DeleteScheduleRequest $request, Server $server, Schedule $schedule): JsonResponse { - $this->repository->delete($schedule->id); + $schedule->delete(); Activity::event('server:schedule.delete')->subject($schedule)->property('name', $schedule->name)->log(); @@ -166,7 +166,7 @@ class ScheduleController extends ClientApiController /** * Get the next run timestamp based on the cron data provided. * - * @throws \Pterodactyl\Exceptions\DisplayException + * @throws DisplayException */ protected function getNextRunAt(Request $request): Carbon { @@ -178,7 +178,7 @@ class ScheduleController extends ClientApiController $request->input('month'), $request->input('day_of_week') ); - } catch (Exception $exception) { + } catch (Exception) { throw new DisplayException('The cron data provided does not evaluate to a valid expression.'); } } diff --git a/app/Providers/RepositoryServiceProvider.php b/app/Providers/RepositoryServiceProvider.php index 8a0434f52..383ccc505 100644 --- a/app/Providers/RepositoryServiceProvider.php +++ b/app/Providers/RepositoryServiceProvider.php @@ -14,7 +14,6 @@ use Pterodactyl\Repositories\Eloquent\SessionRepository; use Pterodactyl\Repositories\Eloquent\SubuserRepository; use Pterodactyl\Repositories\Eloquent\DatabaseRepository; use Pterodactyl\Repositories\Eloquent\LocationRepository; -use Pterodactyl\Repositories\Eloquent\ScheduleRepository; use Pterodactyl\Repositories\Eloquent\SettingsRepository; use Pterodactyl\Repositories\Eloquent\AllocationRepository; use Pterodactyl\Contracts\Repository\EggRepositoryInterface; @@ -31,7 +30,6 @@ use Pterodactyl\Contracts\Repository\SessionRepositoryInterface; use Pterodactyl\Contracts\Repository\SubuserRepositoryInterface; use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface; use Pterodactyl\Contracts\Repository\LocationRepositoryInterface; -use Pterodactyl\Contracts\Repository\ScheduleRepositoryInterface; use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface; use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface; use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface; @@ -55,7 +53,6 @@ class RepositoryServiceProvider extends ServiceProvider $this->app->bind(LocationRepositoryInterface::class, LocationRepository::class); $this->app->bind(NestRepositoryInterface::class, NestRepository::class); $this->app->bind(NodeRepositoryInterface::class, NodeRepository::class); - $this->app->bind(ScheduleRepositoryInterface::class, ScheduleRepository::class); $this->app->bind(ServerRepositoryInterface::class, ServerRepository::class); $this->app->bind(ServerVariableRepositoryInterface::class, ServerVariableRepository::class); $this->app->bind(SessionRepositoryInterface::class, SessionRepository::class); diff --git a/app/Repositories/Eloquent/ScheduleRepository.php b/app/Repositories/Eloquent/ScheduleRepository.php deleted file mode 100644 index 145333f45..000000000 --- a/app/Repositories/Eloquent/ScheduleRepository.php +++ /dev/null @@ -1,42 +0,0 @@ -getBuilder()->withCount('tasks')->where('server_id', '=', $server)->get($this->getColumns()); - } - - /** - * Return a schedule model with all the associated tasks as a relationship. - * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function getScheduleWithTasks(int $schedule): Schedule - { - try { - return $this->getBuilder()->with('tasks')->findOrFail($schedule, $this->getColumns()); - } catch (ModelNotFoundException) { - throw new RecordNotFoundException(); - } - } -}