'integer', 'user_viewable' => 'bool', 'user_editable' => 'bool', ]; public static array $validationRules = [ 'egg_id' => 'exists:eggs,id', 'name' => 'required|string|between:1,191', 'description' => 'string', 'env_variable' => 'required|regex:/^[\w]{1,191}$/|notIn:' . self::RESERVED_ENV_NAMES, 'default_value' => 'string', 'user_viewable' => 'boolean', 'user_editable' => 'boolean', 'rules' => 'required|string', ]; protected $attributes = [ 'user_editable' => 0, 'user_viewable' => 0, ]; public function getRequiredAttribute(): bool { return in_array('required', explode('|', $this->rules)); } public function egg(): HasOne { return $this->hasOne(Egg::class); } /** * Return server variables associated with this variable. */ public function serverVariable(): HasMany { return $this->hasMany(ServerVariable::class, 'variable_id'); } }