*/ use HasFactory; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ public const string RESOURCE_NAME = 'egg_variable'; /** * Reserved environment variable names. */ public const string RESERVED_ENV_NAMES = 'SERVER_MEMORY,SERVER_IP,SERVER_PORT,ENV,HOME,USER,STARTUP,SERVER_UUID,UUID'; protected $attributes = [ 'user_editable' => 0, 'user_viewable' => 0, ]; /** * @return array */ protected function casts(): array { return [ 'egg_id' => 'integer', 'user_viewable' => 'bool', 'user_editable' => 'bool', 'sort_order' => 'integer', ]; } /** * The egg this variable is defined on. * * @return BelongsTo */ public function egg(): BelongsTo { return $this->belongsTo(Egg::class); } /** * Return server variables associated with this variable. * * @return HasMany */ public function serverVariable(): HasMany { return $this->hasMany(ServerVariable::class, 'variable_id'); } /** * @return Attribute */ protected function required(): Attribute { return Attribute::make(get: fn (): bool => in_array('required', explode('|', $this->rules))); } }