mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 00:34:44 +02:00
Fix serverVariables
not saving due to join
(#1235)
* Fix `serverVariables` not saving due to `join` * Remove deprecated `viewableServerVariables`
This commit is contained in:
parent
7409f020ba
commit
02d7ad04ad
@ -426,7 +426,7 @@ class CreateServer extends CreateRecord
|
|||||||
|
|
||||||
Repeater::make('server_variables')
|
Repeater::make('server_variables')
|
||||||
->label('')
|
->label('')
|
||||||
->relationship('serverVariables')
|
->relationship('serverVariables', fn (Builder $query) => $query->orderByPowerJoins('variable.sort'))
|
||||||
->saveRelationshipsBeforeChildrenUsing(null)
|
->saveRelationshipsBeforeChildrenUsing(null)
|
||||||
->saveRelationshipsUsing(null)
|
->saveRelationshipsUsing(null)
|
||||||
->grid(2)
|
->grid(2)
|
||||||
|
@ -595,9 +595,7 @@ class EditServer extends EditRecord
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query
|
return $query->orderByPowerJoins('variable.sort');
|
||||||
->join('egg_variables', 'server_variables.variable_id', '=', 'egg_variables.id')
|
|
||||||
->orderBy('egg_variables.sort');
|
|
||||||
})
|
})
|
||||||
->grid()
|
->grid()
|
||||||
->mutateRelationshipDataBeforeSaveUsing(function (array &$data): array {
|
->mutateRelationshipDataBeforeSaveUsing(function (array &$data): array {
|
||||||
|
@ -18,6 +18,7 @@ use Filament\Forms\Components\Textarea;
|
|||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
class Startup extends ServerFormPage
|
class Startup extends ServerFormPage
|
||||||
@ -100,7 +101,7 @@ class Startup extends ServerFormPage
|
|||||||
->schema([
|
->schema([
|
||||||
Repeater::make('server_variables')
|
Repeater::make('server_variables')
|
||||||
->label('')
|
->label('')
|
||||||
->relationship('viewableServerVariables')
|
->relationship('serverVariables', fn (Builder $query) => $query->where('egg_variables.user_viewable', true)->orderByPowerJoins('variable.sort'))
|
||||||
->grid()
|
->grid()
|
||||||
->disabled(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server))
|
->disabled(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server))
|
||||||
->reorderable(false)->addable(false)->deletable(false)
|
->reorderable(false)->addable(false)->deletable(false)
|
||||||
|
@ -37,7 +37,7 @@ class StartupController extends ClientApiController
|
|||||||
$startup = $this->startupCommandService->handle($server);
|
$startup = $this->startupCommandService->handle($server);
|
||||||
|
|
||||||
return $this->fractal->collection(
|
return $this->fractal->collection(
|
||||||
$server->variables()->orderBy('sort')->where('user_viewable', true)->get()
|
$server->variables()->where('user_viewable', true)->orderBy('sort')->get()
|
||||||
)
|
)
|
||||||
->transformWith($this->getTransformer(EggVariableTransformer::class))
|
->transformWith($this->getTransformer(EggVariableTransformer::class))
|
||||||
->addMeta([
|
->addMeta([
|
||||||
|
@ -310,15 +310,6 @@ class Server extends Model implements Validatable
|
|||||||
return $this->hasMany(ServerVariable::class);
|
return $this->hasMany(ServerVariable::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @deprecated use serverVariables */
|
|
||||||
public function viewableServerVariables(): HasMany
|
|
||||||
{
|
|
||||||
return $this->serverVariables()
|
|
||||||
->join('egg_variables', 'egg_variables.id', '=', 'server_variables.variable_id')
|
|
||||||
->orderBy('egg_variables.sort')
|
|
||||||
->where('egg_variables.user_viewable', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets information for the node associated with this server.
|
* Gets information for the node associated with this server.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user