mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-29 10:54:46 +02:00
Better this
This commit is contained in:
parent
7e5d21a889
commit
ae0882740a
@ -7,7 +7,6 @@ use App\Models\Server;
|
|||||||
use App\Models\Allocation;
|
use App\Models\Allocation;
|
||||||
use Illuminate\Database\ConnectionInterface;
|
use Illuminate\Database\ConnectionInterface;
|
||||||
use App\Exceptions\DisplayException;
|
use App\Exceptions\DisplayException;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|
||||||
use App\Repositories\Daemon\DaemonServerRepository;
|
use App\Repositories\Daemon\DaemonServerRepository;
|
||||||
use App\Exceptions\Http\Connection\DaemonConnectionException;
|
use App\Exceptions\Http\Connection\DaemonConnectionException;
|
||||||
|
|
||||||
@ -36,15 +35,12 @@ class BuildModificationService
|
|||||||
$this->processAllocations($server, $data);
|
$this->processAllocations($server, $data);
|
||||||
|
|
||||||
if (isset($data['allocation_id']) && $data['allocation_id'] != $server->allocation_id) {
|
if (isset($data['allocation_id']) && $data['allocation_id'] != $server->allocation_id) {
|
||||||
try {
|
$existingAllocation = $server->allocations()->findOrFail($data['allocation_id']);
|
||||||
Allocation::query()->where('id', $data['allocation_id'])->where('server_id', $server->id)->firstOrFail();
|
|
||||||
} catch (ModelNotFoundException) {
|
throw_unless($existingAllocation, new DisplayException('The requested default allocation is not currently assigned to this server.'));
|
||||||
throw new DisplayException('The requested default allocation is not currently assigned to this server.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If any of these values are passed through in the data array go ahead and set
|
// If any of these values are passed through in the data array go ahead and set them correctly on the server model.
|
||||||
// them correctly on the server model.
|
|
||||||
$merge = Arr::only($data, ['oom_disabled', 'memory', 'swap', 'io', 'cpu', 'threads', 'disk', 'allocation_id']);
|
$merge = Arr::only($data, ['oom_disabled', 'memory', 'swap', 'io', 'cpu', 'threads', 'disk', 'allocation_id']);
|
||||||
|
|
||||||
$server->forceFill(array_merge($merge, [
|
$server->forceFill(array_merge($merge, [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user