Skip to content

Commit

Permalink
[6.x] Convert $casts property to method on Eloquent models (#11499)
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean authored Feb 25, 2025
1 parent 184751b commit 570a633
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
15 changes: 9 additions & 6 deletions src/Auth/Eloquent/RoleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ class RoleModel extends Eloquent

protected $table = 'roles';

protected $casts = [
'permissions' => 'json',
'preferences' => 'json',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
protected function casts(): array
{
return [
'permissions' => 'json',
'preferences' => 'json',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
}

public function __construct(array $attributes = [])
{
Expand Down
15 changes: 9 additions & 6 deletions src/Auth/Eloquent/UserGroupModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ class UserGroupModel extends Eloquent

protected $table = 'groups';

protected $casts = [
'roles' => 'json',
'data' => 'json',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
protected function casts(): array
{
return [
'roles' => 'json',
'data' => 'json',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
}

public function __construct(array $attributes = [])
{
Expand Down
9 changes: 6 additions & 3 deletions src/StaticCaching/NoCache/DatabaseRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class DatabaseRegion extends Model

protected $primaryKey = 'key';

protected $casts = [
'key' => 'string',
];
protected function casts(): array
{
return [
'key' => 'string',
];
}
}

0 comments on commit 570a633

Please sign in to comment.