22
33namespace Pterodactyl \Models ;
44
5+ /**
6+ * @property int $id
7+ * @property int $egg_id
8+ * @property string $name
9+ * @property string $description
10+ * @property string $env_variable
11+ * @property string $default_value
12+ * @property bool $user_viewable
13+ * @property bool $user_editable
14+ * @property string $rules
15+ * @property \Carbon\CarbonImmutable $created_at
16+ * @property \Carbon\CarbonImmutable $updated_at
17+ *
18+ * @property bool $required
19+ * @property \Pterodactyl\Models\Egg $egg
20+ * @property \Pterodactyl\Models\ServerVariable $serverVariable
21+ *
22+ * The "server_value" variable is only present on the object if you've loaded this model
23+ * using the server relationship.
24+ * @property string|null $server_value
25+ */
526class EggVariable extends Model
627{
728 /**
@@ -17,6 +38,11 @@ class EggVariable extends Model
1738 */
1839 const RESERVED_ENV_NAMES = 'SERVER_MEMORY,SERVER_IP,SERVER_PORT,ENV,HOME,USER,STARTUP,SERVER_UUID,UUID ' ;
1940
41+ /**
42+ * @var bool
43+ */
44+ protected $ immutableDates = true ;
45+
2046 /**
2147 * The table associated with the model.
2248 *
@@ -38,8 +64,8 @@ class EggVariable extends Model
3864 */
3965 protected $ casts = [
4066 'egg_id ' => 'integer ' ,
41- 'user_viewable ' => 'integer ' ,
42- 'user_editable ' => 'integer ' ,
67+ 'user_viewable ' => 'bool ' ,
68+ 'user_editable ' => 'bool ' ,
4369 ];
4470
4571 /**
@@ -65,12 +91,19 @@ class EggVariable extends Model
6591 ];
6692
6793 /**
68- * @param $value
6994 * @return bool
7095 */
71- public function getRequiredAttribute ($ value )
96+ public function getRequiredAttribute ()
97+ {
98+ return in_array ('required ' , explode ('| ' , $ this ->rules ));
99+ }
100+
101+ /**
102+ * @return \Illuminate\Database\Eloquent\Relations\HasOne
103+ */
104+ public function egg ()
72105 {
73- return $ this ->rules === ' required ' || str_contains ( $ this -> rules , [ ' required| ' , ' |required ' ] );
106+ return $ this ->hasOne (Egg::class );
74107 }
75108
76109 /**
0 commit comments