diff --git a/app/Contracts/Repository/EggVariableRepositoryInterface.php b/app/Contracts/Repository/EggVariableRepositoryInterface.php deleted file mode 100644 index e20080818..000000000 --- a/app/Contracts/Repository/EggVariableRepositoryInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -variableRepository->delete($variable->id); + $variable->delete(); $this->alert->success(trans('admin/nests.variables.notices.variable_deleted', [ 'variable' => $variable->name, ]))->flash(); diff --git a/app/Providers/RepositoryServiceProvider.php b/app/Providers/RepositoryServiceProvider.php index 8a0434f52..fa7bfdc87 100644 --- a/app/Providers/RepositoryServiceProvider.php +++ b/app/Providers/RepositoryServiceProvider.php @@ -18,7 +18,6 @@ use Pterodactyl\Repositories\Eloquent\ScheduleRepository; use Pterodactyl\Repositories\Eloquent\SettingsRepository; use Pterodactyl\Repositories\Eloquent\AllocationRepository; 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; @@ -34,7 +33,6 @@ 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; use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface; use Pterodactyl\Contracts\Repository\ServerVariableRepositoryInterface; @@ -51,7 +49,6 @@ class RepositoryServiceProvider extends ServiceProvider $this->app->bind(DatabaseRepositoryInterface::class, DatabaseRepository::class); $this->app->bind(DatabaseHostRepositoryInterface::class, DatabaseHostRepository::class); $this->app->bind(EggRepositoryInterface::class, EggRepository::class); - $this->app->bind(EggVariableRepositoryInterface::class, EggVariableRepository::class); $this->app->bind(LocationRepositoryInterface::class, LocationRepository::class); $this->app->bind(NestRepositoryInterface::class, NestRepository::class); $this->app->bind(NodeRepositoryInterface::class, NodeRepository::class); diff --git a/app/Repositories/Eloquent/EggVariableRepository.php b/app/Repositories/Eloquent/EggVariableRepository.php deleted file mode 100644 index 8ca35debb..000000000 --- a/app/Repositories/Eloquent/EggVariableRepository.php +++ /dev/null @@ -1,31 +0,0 @@ -getBuilder()->where([ - ['egg_id', '=', $egg], - ['user_viewable', '=', 1], - ['user_editable', '=', 1], - ])->get($this->getColumns()); - } -} diff --git a/app/Services/Eggs/Variables/VariableCreationService.php b/app/Services/Eggs/Variables/VariableCreationService.php index a7e19f6ba..fe99c9f39 100644 --- a/app/Services/Eggs/Variables/VariableCreationService.php +++ b/app/Services/Eggs/Variables/VariableCreationService.php @@ -5,7 +5,6 @@ namespace Pterodactyl\Services\Eggs\Variables; use Pterodactyl\Models\EggVariable; use Pterodactyl\Traits\Services\ValidatesValidationRules; use Illuminate\Contracts\Validation\Factory as ValidationFactory; -use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface; use Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException; class VariableCreationService @@ -15,7 +14,7 @@ class VariableCreationService /** * VariableCreationService constructor. */ - public function __construct(private EggVariableRepositoryInterface $repository, private ValidationFactory $validator) + public function __construct(private ValidationFactory $validator) { } @@ -47,7 +46,8 @@ class VariableCreationService $options = array_get($data, 'options') ?? []; - return $this->repository->create([ + /** @var EggVariable $eggVariable */ + $eggVariable = EggVariable::query()->create([ 'egg_id' => $egg, 'name' => $data['name'] ?? '', 'description' => $data['description'] ?? '', @@ -57,5 +57,7 @@ class VariableCreationService 'user_editable' => in_array('user_editable', $options), 'rules' => $data['rules'] ?? '', ]); + + return $eggVariable; } } diff --git a/app/Services/Eggs/Variables/VariableUpdateService.php b/app/Services/Eggs/Variables/VariableUpdateService.php index ed70b260f..ef75e4a9c 100644 --- a/app/Services/Eggs/Variables/VariableUpdateService.php +++ b/app/Services/Eggs/Variables/VariableUpdateService.php @@ -7,7 +7,6 @@ use Pterodactyl\Models\EggVariable; use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Traits\Services\ValidatesValidationRules; use Illuminate\Contracts\Validation\Factory as ValidationFactory; -use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface; use Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException; class VariableUpdateService @@ -17,7 +16,7 @@ class VariableUpdateService /** * VariableUpdateService constructor. */ - public function __construct(private EggVariableRepositoryInterface $repository, private ValidationFactory $validator) + public function __construct(private ValidationFactory $validator) { } @@ -45,11 +44,11 @@ class VariableUpdateService throw new ReservedVariableNameException(trans('exceptions.service.variables.reserved_name', ['name' => array_get($data, 'env_variable')])); } - $search = $this->repository->setColumns('id')->findCountWhere([ - ['env_variable', '=', $data['env_variable']], - ['egg_id', '=', $variable->egg_id], - ['id', '!=', $variable->id], - ]); + $search = EggVariable::query() + ->where('env_variable', $data['env_variable']) + ->where('egg_id', $variable->egg_id) + ->whereNot('id', $variable->id) + ->count(); if ($search > 0) { throw new DisplayException(trans('exceptions.service.variables.env_not_unique', ['name' => array_get($data, 'env_variable')])); @@ -66,7 +65,7 @@ class VariableUpdateService $options = array_get($data, 'options') ?? []; - return $this->repository->withoutFreshModel()->update($variable->id, [ + return $variable->update([ 'name' => $data['name'] ?? '', 'description' => $data['description'] ?? '', 'env_variable' => $data['env_variable'] ?? '',