Remove server variable repository

This commit is contained in:
Lance Pioch 2024-03-16 19:32:24 -04:00
parent a0cc4b3d5f
commit 384612360e
5 changed files with 4 additions and 33 deletions

View File

@ -1,7 +0,0 @@
<?php
namespace App\Contracts\Repository;
interface ServerVariableRepositoryInterface extends RepositoryInterface
{
}

View File

@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api\Client\Servers;
use App\Models\Server;
use App\Facades\Activity;
use App\Models\ServerVariable;
use App\Services\Servers\StartupCommandService;
use App\Repositories\Eloquent\ServerVariableRepository;
use App\Transformers\Api\Client\EggVariableTransformer;
use App\Http\Controllers\Api\Client\ClientApiController;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@ -19,7 +19,6 @@ class StartupController extends ClientApiController
*/
public function __construct(
private StartupCommandService $startupCommandService,
private ServerVariableRepository $repository
) {
parent::__construct();
}
@ -66,7 +65,7 @@ class StartupController extends ClientApiController
// Revalidate the variable value using the egg variable specific validation rules for it.
$this->validate($request, ['value' => $variable->rules]);
$this->repository->updateOrCreate([
ServerVariable::query()->updateOrCreate([
'server_id' => $server->id,
'variable_id' => $variable->id,
], [

View File

@ -16,7 +16,6 @@ use App\Repositories\Eloquent\EggVariableRepository;
use App\Contracts\Repository\NodeRepositoryInterface;
use App\Repositories\Eloquent\DatabaseHostRepository;
use App\Contracts\Repository\ApiKeyRepositoryInterface;
use App\Repositories\Eloquent\ServerVariableRepository;
use App\Contracts\Repository\SessionRepositoryInterface;
use App\Contracts\Repository\SubuserRepositoryInterface;
use App\Contracts\Repository\DatabaseRepositoryInterface;
@ -24,7 +23,6 @@ use App\Contracts\Repository\SettingsRepositoryInterface;
use App\Contracts\Repository\AllocationRepositoryInterface;
use App\Contracts\Repository\EggVariableRepositoryInterface;
use App\Contracts\Repository\DatabaseHostRepositoryInterface;
use App\Contracts\Repository\ServerVariableRepositoryInterface;
class RepositoryServiceProvider extends ServiceProvider
{
@ -41,7 +39,6 @@ class RepositoryServiceProvider extends ServiceProvider
$this->app->bind(EggRepositoryInterface::class, EggRepository::class);
$this->app->bind(EggVariableRepositoryInterface::class, EggVariableRepository::class);
$this->app->bind(NodeRepositoryInterface::class, NodeRepository::class);
$this->app->bind(ServerVariableRepositoryInterface::class, ServerVariableRepository::class);
$this->app->bind(SessionRepositoryInterface::class, SessionRepository::class);
$this->app->bind(SettingsRepositoryInterface::class, SettingsRepository::class);
$this->app->bind(SubuserRepositoryInterface::class, SubuserRepository::class);

View File

@ -1,17 +0,0 @@
<?php
namespace App\Repositories\Eloquent;
use App\Models\ServerVariable;
use App\Contracts\Repository\ServerVariableRepositoryInterface;
class ServerVariableRepository extends EloquentRepository implements ServerVariableRepositoryInterface
{
/**
* Return the model backing this repository.
*/
public function model(): string
{
return ServerVariable::class;
}
}

View File

@ -2,6 +2,7 @@
namespace App\Services\Servers;
use App\Models\ServerVariable;
use Ramsey\Uuid\Uuid;
use Illuminate\Support\Arr;
use App\Models\User;
@ -13,7 +14,6 @@ use Illuminate\Database\ConnectionInterface;
use App\Models\Objects\DeploymentObject;
use App\Repositories\Daemon\DaemonServerRepository;
use App\Services\Deployment\FindViableNodesService;
use App\Repositories\Eloquent\ServerVariableRepository;
use App\Services\Deployment\AllocationSelectionService;
use App\Exceptions\Http\Connection\DaemonConnectionException;
@ -28,7 +28,6 @@ class ServerCreationService
private DaemonServerRepository $daemonServerRepository,
private FindViableNodesService $findViableNodesService,
private ServerDeletionService $serverDeletionService,
private ServerVariableRepository $serverVariableRepository,
private VariableValidatorService $validatorService
) {
}
@ -183,7 +182,7 @@ class ServerCreationService
})->toArray();
if (!empty($records)) {
$this->serverVariableRepository->insert($records);
ServerVariable::query()->insert($records);
}
}