Update repository base code to be cleaner and make use of PHP 7 features

This commit is contained in:
Dane Everitt 2018-01-04 22:49:50 -06:00
parent 0ec5a4e08c
commit 60eb60013c
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
96 changed files with 1048 additions and 1785 deletions

View file

@ -96,7 +96,7 @@ class EggUpdateImporterService
});
$imported = collect($parsed->variables)->pluck('env_variable')->toArray();
$existing = $this->variableRepository->withColumns(['id', 'env_variable'])->findWhere([['egg_id', '=', $egg]]);
$existing = $this->variableRepository->setColumns(['id', 'env_variable'])->findWhere([['egg_id', '=', $egg]]);
// Delete variables not present in the import.
collect($existing)->each(function ($variable) use ($egg, $imported) {

View file

@ -49,7 +49,7 @@ class VariableUpdateService
]));
}
$search = $this->repository->withColumns('id')->findCountWhere([
$search = $this->repository->setColumns('id')->findCountWhere([
['env_variable', '=', array_get($data, 'env_variable')],
['egg_id', '=', $variable->egg_id],
['id', '!=', $variable->id],

View file

@ -63,7 +63,7 @@ class NodeDeletionService
$node = $node->id;
}
$servers = $this->serverRepository->withColumns('id')->findCountWhere([['node_id', '=', $node]]);
$servers = $this->serverRepository->setColumns('id')->findCountWhere([['node_id', '=', $node]]);
if ($servers > 0) {
throw new HasActiveServersException($this->translator->trans('exceptions.node.servers_attached'));
}

View file

@ -69,7 +69,7 @@ class PackDeletionService
public function handle($pack)
{
if (! $pack instanceof Pack) {
$pack = $this->repository->withColumns(['id', 'uuid'])->find($pack);
$pack = $this->repository->setColumns(['id', 'uuid'])->find($pack);
}
$count = $this->serverRepository->findCountWhere([['pack_id', '=', $pack->id]]);

View file

@ -54,7 +54,7 @@ class PackUpdateService
public function handle($pack, array $data)
{
if (! $pack instanceof Pack) {
$pack = $this->repository->withColumns(['id', 'egg_id'])->find($pack);
$pack = $this->repository->setColumns(['id', 'egg_id'])->find($pack);
}
if ((int) array_get($data, 'egg_id', $pack->egg_id) !== $pack->egg_id) {

View file

@ -106,7 +106,7 @@ class ServerDeletionService
public function handle($server)
{
if (! $server instanceof Server) {
$server = $this->repository->withColumns(['id', 'node_id', 'uuid'])->find($server);
$server = $this->repository->setColumns(['id', 'node_id', 'uuid'])->find($server);
}
try {
@ -128,7 +128,7 @@ class ServerDeletionService
}
$this->connection->beginTransaction();
$this->databaseRepository->withColumns('id')->findWhere([['server_id', '=', $server->id]])->each(function ($item) {
$this->databaseRepository->setColumns('id')->findWhere([['server_id', '=', $server->id]])->each(function ($item) {
$this->databaseManagementService->delete($item->id);
});

View file

@ -68,7 +68,7 @@ class AuthenticateUsingPasswordService
}
try {
$user = $this->userRepository->withColumns(['id', 'root_admin', 'password'])->findFirstWhere([['username', '=', $username]]);
$user = $this->userRepository->setColumns(['id', 'root_admin', 'password'])->findFirstWhere([['username', '=', $username]]);
if (! password_verify($password, $user->password)) {
throw new AuthenticationException;
@ -77,7 +77,7 @@ class AuthenticateUsingPasswordService
throw new AuthenticationException;
}
$server = $this->repository->withColumns(['id', 'node_id', 'owner_id', 'uuid'])->getByUuid($server);
$server = $this->repository->setColumns(['id', 'node_id', 'owner_id', 'uuid'])->getByUuid($server);
if ($server->node_id !== $node || (! $user->root_admin && $server->owner_id !== $user->id)) {
throw new RecordNotFoundException;
}

View file

@ -63,7 +63,7 @@ class UserDeletionService
$user = $user->id;
}
$servers = $this->serverRepository->withColumns('id')->findCountWhere([['owner_id', '=', $user]]);
$servers = $this->serverRepository->setColumns('id')->findCountWhere([['owner_id', '=', $user]]);
if ($servers > 0) {
throw new DisplayException($this->translator->trans('admin/user.exceptions.user_has_servers'));
}