diff --git a/app/Filament/Admin/Resources/EggResource/Pages/CreateEgg.php b/app/Filament/Admin/Resources/EggResource/Pages/CreateEgg.php index f17ad531b1..09188a15ab 100644 --- a/app/Filament/Admin/Resources/EggResource/Pages/CreateEgg.php +++ b/app/Filament/Admin/Resources/EggResource/Pages/CreateEgg.php @@ -4,6 +4,7 @@ use AbdelhamidErrahmouni\FilamentMonacoEditor\MonacoEditor; use App\Filament\Admin\Resources\EggResource; +use App\Models\EggVariable; use Filament\Forms\Components\Checkbox; use Filament\Forms\Components\Fieldset; use Filament\Forms\Components\Hidden; @@ -189,8 +190,11 @@ public function form(Form $form): Form ->hintIcon('tabler-code') ->hintIconTooltip(fn ($state) => "{{{$state}}}") ->unique(modifyRuleUsing: fn (Unique $rule, Get $get) => $rule->where('egg_id', $get('../../id')), ignoreRecord: true) + ->rules(EggVariable::$validationRules['env_variable']) ->validationMessages([ 'unique' => 'A variable with this name already exists.', + 'required' => ' The environment variable field is required.', + '*' => 'This environment variable is reserved and cannot be used.', ]) ->required(), TextInput::make('default_value')->maxLength(255), diff --git a/app/Filament/Admin/Resources/EggResource/Pages/EditEgg.php b/app/Filament/Admin/Resources/EggResource/Pages/EditEgg.php index 5bd30de3fe..08596163da 100644 --- a/app/Filament/Admin/Resources/EggResource/Pages/EditEgg.php +++ b/app/Filament/Admin/Resources/EggResource/Pages/EditEgg.php @@ -8,6 +8,7 @@ use App\Filament\Components\Actions\ExportEggAction; use App\Filament\Components\Actions\ImportEggAction; use App\Models\Egg; +use App\Models\EggVariable; use Filament\Actions\DeleteAction; use Filament\Forms\Components\Checkbox; use Filament\Forms\Components\Fieldset; @@ -180,8 +181,11 @@ public function form(Form $form): Form ->hintIcon('tabler-code') ->hintIconTooltip(fn ($state) => "{{{$state}}}") ->unique(modifyRuleUsing: fn (Unique $rule, Get $get) => $rule->where('egg_id', $get('../../id')), ignoreRecord: true) + ->rules(EggVariable::$validationRules['env_variable']) ->validationMessages([ 'unique' => 'A variable with this name already exists.', + 'required' => ' The environment variable field is required.', + '*' => 'This environment variable is reserved and cannot be used.', ]) ->required(), TextInput::make('default_value')->maxLength(255), diff --git a/app/Models/EggVariable.php b/app/Models/EggVariable.php index 2d3a4fb2c5..6d998470db 100644 --- a/app/Models/EggVariable.php +++ b/app/Models/EggVariable.php @@ -37,7 +37,7 @@ class EggVariable extends Model /** * Reserved environment variable names. */ - public const RESERVED_ENV_NAMES = 'SERVER_MEMORY,SERVER_IP,SERVER_PORT,ENV,HOME,USER,STARTUP,SERVER_UUID,UUID'; + public const RESERVED_ENV_NAMES = 'P_SERVER_UUID,P_SERVER_ALLOCATION_LIMIT,SERVER_MEMORY,SERVER_IP,SERVER_PORT,ENV,HOME,USER,STARTUP,MODIFIED_STARTUP,SERVER_UUID,UUID,INTERNAL_IP'; /** * The table associated with the model.