Model Type Casting

This commit is contained in:
Refringe 2024-10-12 13:18:04 -06:00
parent d4d0a1495a
commit 4b4abceb1f
Signed by: Refringe
SSH Key Fingerprint: SHA256:t865XsQpfTeqPRBMN2G6+N8wlDjkgUCZF3WGW6O9N/k
7 changed files with 83 additions and 0 deletions

View File

@ -22,4 +22,17 @@ class License extends Model
return $this->hasMany(Mod::class) return $this->hasMany(Mod::class)
->chaperone(); ->chaperone();
} }
/**
* The attributes that should be cast to native types.
*/
protected function casts(): array
{
return [
'hub_id' => 'integer',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
}
} }

View File

@ -243,6 +243,7 @@ class Mod extends Model
'created_at' => 'datetime', 'created_at' => 'datetime',
'updated_at' => 'datetime', 'updated_at' => 'datetime',
'deleted_at' => 'datetime', 'deleted_at' => 'datetime',
'published_at' => 'datetime',
]; ];
} }

View File

@ -41,4 +41,15 @@ class ModDependency extends Model
{ {
return $this->belongsTo(Mod::class, 'dependent_mod_id'); return $this->belongsTo(Mod::class, 'dependent_mod_id');
} }
/**
* The attributes that should be cast to native types.
*/
protected function casts(): array
{
return [
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
}
} }

View File

@ -36,4 +36,15 @@ class ModResolvedDependency extends Model
{ {
return $this->belongsTo(ModVersion::class, 'resolved_mod_version_id'); return $this->belongsTo(ModVersion::class, 'resolved_mod_version_id');
} }
/**
* The attributes that should be cast to native types.
*/
protected function casts(): array
{
return [
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
}
} }

View File

@ -152,4 +152,23 @@ class ModVersion extends Model
return $this->downloads; return $this->downloads;
} }
/**
* The attributes that should be cast to native types.
*/
protected function casts(): array
{
return [
'hub_id' => 'integer',
'version_major' => 'integer',
'version_minor' => 'integer',
'version_patch' => 'integer',
'downloads' => 'integer',
'disabled' => 'boolean',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
'published_at' => 'datetime',
];
}
} }

View File

@ -16,4 +16,15 @@ class OAuthConnection extends Model
{ {
return $this->belongsTo(User::class); return $this->belongsTo(User::class);
} }
/**
* The attributes that should be cast to native types.
*/
protected function casts(): array
{
return [
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
}
} }

View File

@ -172,4 +172,21 @@ class SptVersion extends Model
->first(); ->first();
}); });
} }
/**
* The attributes that should be cast to native types.
*/
protected function casts(): array
{
return [
'hub_id' => 'integer',
'version_major' => 'integer',
'version_minor' => 'integer',
'version_patch' => 'integer',
'mod_count' => 'integer',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
}
} }