<?php12namespace Pterodactyl\Models;34use Illuminate\Database\Eloquent\Relations\HasOne;5use Illuminate\Database\Eloquent\Relations\HasMany;6use Illuminate\Database\Eloquent\Factories\HasFactory;78/**9* @property int $id10* @property int $egg_id11* @property string $name12* @property string $description13* @property string $env_variable14* @property string $default_value15* @property bool $user_viewable16* @property bool $user_editable17* @property string $rules18* @property \Carbon\CarbonImmutable $created_at19* @property \Carbon\CarbonImmutable $updated_at20* @property bool $required21* @property Egg $egg22* @property ServerVariable $serverVariable23*24* The "server_value" variable is only present on the object if you've loaded this model25* using the server relationship.26* @property string|null $server_value27*/28class EggVariable extends Model29{30/** @use HasFactory<\Database\Factories\EggVariableFactory> */31use HasFactory;3233/**34* The resource name for this model when it is transformed into an35* API representation using fractal.36*/37public const RESOURCE_NAME = 'egg_variable';3839/**40* Reserved environment variable names.41*/42public const RESERVED_ENV_NAMES = 'SERVER_MEMORY,SERVER_IP,SERVER_PORT,ENV,HOME,USER,STARTUP,SERVER_UUID,UUID';4344protected bool $immutableDates = true;4546/**47* The table associated with the model.48*/49protected $table = 'egg_variables';5051/**52* Fields that are not mass assignable.53*/54protected $guarded = ['id', 'created_at', 'updated_at'];5556/**57* Cast values to correct type.58*/59protected $casts = [60'egg_id' => 'integer',61'user_viewable' => 'bool',62'user_editable' => 'bool',63];6465public static array $validationRules = [66'egg_id' => 'exists:eggs,id',67'name' => 'required|string|between:1,191',68'description' => 'string',69'env_variable' => 'required|regex:/^[\w]{1,191}$/|notIn:' . self::RESERVED_ENV_NAMES,70'default_value' => 'string',71'user_viewable' => 'boolean',72'user_editable' => 'boolean',73'rules' => 'required|string',74];7576protected $attributes = [77'user_editable' => 0,78'user_viewable' => 0,79];8081public function getRequiredAttribute(): bool82{83return in_array('required', explode('|', $this->rules));84}8586/**87* @return \Illuminate\Database\Eloquent\Relations\HasOne<\Pterodactyl\Models\Egg, $this>88*/89public function egg(): HasOne90{91return $this->hasOne(Egg::class);92}9394/**95* Return server variables associated with this variable.96*97* @return \Illuminate\Database\Eloquent\Relations\HasMany<\Pterodactyl\Models\ServerVariable, $this>98*/99public function serverVariable(): HasMany100{101return $this->hasMany(ServerVariable::class, 'variable_id');102}103}104105106