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