*/ public static array $validationRules = [ 'egg_id' => ['exists:eggs,id'], 'sort' => ['nullable'], 'name' => ['required', 'string', 'between:1,255'], 'description' => ['string'], 'default_value' => ['string'], 'user_viewable' => ['boolean'], 'user_editable' => ['boolean'], 'rules' => ['array'], 'rules.*' => ['string'], ]; /** * Implement language verification by overriding Eloquence's gather rules function. * * @return array */ public static function getRules(): array { $rules = self::getValidationRules(); $rules['env_variable'] = ['required', 'alphaDash', 'between:1,255', 'notIn:' . implode(',', EggVariable::RESERVED_ENV_NAMES)]; return $rules; } protected $attributes = [ 'user_editable' => 0, 'user_viewable' => 0, 'rules' => '[]', ]; protected function casts(): array { return [ 'egg_id' => 'integer', 'user_viewable' => 'bool', 'user_editable' => 'bool', 'rules' => 'array', 'created_at' => 'immutable_datetime', 'updated_at' => 'immutable_datetime', ]; } public function getRequiredAttribute(): bool { return in_array('required', $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'); } }