Fix egg variable saving

This commit is contained in:
Lance Pioch 2024-04-21 15:57:15 -04:00
parent 3ad622dd69
commit dfaff50ca1
2 changed files with 20 additions and 6 deletions

View File

@ -77,23 +77,37 @@ class EggResource extends Resource
->label('Log Configuration') ->label('Log Configuration')
->helperText('This should be a JSON representation of where log files are stored, and whether or not the daemon should be creating custom logs.'), ->helperText('This should be a JSON representation of where log files are stored, and whether or not the daemon should be creating custom logs.'),
]), ]),
Forms\Components\Tabs\Tab::make('Variables') Forms\Components\Tabs\Tab::make('Egg Variables')
->columnSpanFull() ->columnSpanFull()
// ->columns(2) // ->columns(2)
->schema([ ->schema([
Forms\Components\Repeater::make('Blah') Forms\Components\Repeater::make('variables')
->grid(3) ->grid(3)
->relationship('variables') ->relationship('variables')
->name('name') ->name('name')
->columns(1) ->columns(1)
->columnSpan(1) ->columnSpan(1)
->itemLabel(fn (array $state) => $state['name']) ->itemLabel(fn (array $state) => $state['name'])
->mutateRelationshipDataBeforeCreateUsing(function (array $data): array {
$data['default_value'] ??= '';
$data['description'] ??= '';
$data['rules'] ??= '';
return $data;
})
->mutateRelationshipDataBeforeSaveUsing(function (array $data): array {
$data['default_value'] ??= '';
$data['description'] ??= '';
$data['rules'] ??= '';
return $data;
})
->schema([ ->schema([
Forms\Components\TextInput::make('name')->live()->maxLength(191)->columnSpanFull(), Forms\Components\TextInput::make('name')->live()->maxLength(191)->columnSpanFull()->required(),
Forms\Components\Textarea::make('description')->columnSpanFull(), Forms\Components\Textarea::make('description')->columnSpanFull(),
Forms\Components\TextInput::make('env_variable')->maxLength(191), Forms\Components\TextInput::make('env_variable')->maxLength(191)->required(),
Forms\Components\TextInput::make('default_value')->maxLength(191), Forms\Components\TextInput::make('default_value')->maxLength(191),
Forms\Components\Textarea::make('rules')->rows(3)->columnSpanFull()->required(), Forms\Components\Textarea::make('rules')->rows(3)->columnSpanFull(),
]), ]),
]), ]),
Forms\Components\Tabs\Tab::make('Install Script') Forms\Components\Tabs\Tab::make('Install Script')

View File

@ -56,7 +56,7 @@ class EggVariable extends Model
'default_value' => 'string', 'default_value' => 'string',
'user_viewable' => 'boolean', 'user_viewable' => 'boolean',
'user_editable' => 'boolean', 'user_editable' => 'boolean',
'rules' => 'required|string', 'rules' => 'string',
]; ];
protected $attributes = [ protected $attributes = [