Skip to content

Commit

Permalink
Convert $casts property to method
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Feb 25, 2025
1 parent 6f0ece8 commit bc82a44
Show file tree
Hide file tree
Showing 17 changed files with 116 additions and 65 deletions.
9 changes: 6 additions & 3 deletions src/Assets/AssetContainerModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ class AssetContainerModel extends BaseModel

protected $table = 'asset_containers';

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

public function getAttribute($key)
{
Expand Down
11 changes: 7 additions & 4 deletions src/Assets/AssetModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ class AssetModel extends BaseModel

protected $table = 'assets_meta';

protected $casts = [
'data' => 'json',
'meta' => 'json',
];
protected function casts(): array
{
return [
'data' => 'json',
'meta' => 'json',
];
}
}
25 changes: 14 additions & 11 deletions src/Collections/CollectionModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ class CollectionModel extends BaseModel

protected $table = 'collections';

protected $casts = [
'settings' => 'json',
'settings.routes' => 'array',
'settings.inject' => 'array',
'settings.taxonomies' => 'array',
'settings.structure' => 'array',
'settings.sites' => 'array',
'settings.revisions' => 'boolean',
'settings.dated' => 'boolean',
'settings.default_publish_state' => 'boolean',
];
protected function casts(): array
{
return [
'settings' => 'json',
'settings.routes' => 'array',
'settings.inject' => 'array',
'settings.taxonomies' => 'array',
'settings.structure' => 'array',
'settings.sites' => 'array',
'settings.revisions' => 'boolean',
'settings.dated' => 'boolean',
'settings.default_publish_state' => 'boolean',
];
}
}
13 changes: 8 additions & 5 deletions src/Entries/EntryModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ class EntryModel extends BaseModel

protected $table = 'entries';

protected $casts = [
'date' => 'datetime',
'data' => 'json',
'published' => 'boolean',
];
protected function casts(): array
{
return [
'date' => 'datetime',
'data' => 'json',
'published' => 'boolean',
];
}

public function author()
{
Expand Down
9 changes: 6 additions & 3 deletions src/Fields/BlueprintModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ class BlueprintModel extends BaseModel

protected $table = 'blueprints';

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

public function getAttribute($key)
{
Expand Down
9 changes: 6 additions & 3 deletions src/Fields/FieldsetModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ class FieldsetModel extends BaseModel

protected $table = 'fieldsets';

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

public function getAttribute($key)
{
Expand Down
9 changes: 6 additions & 3 deletions src/Forms/FormModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class FormModel extends BaseModel

protected $table = 'forms';

protected $casts = [
'settings' => 'json',
];
protected function casts(): array
{
return [
'settings' => 'json',
];
}
}
9 changes: 6 additions & 3 deletions src/Forms/SubmissionModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ class SubmissionModel extends BaseModel

protected $table = 'form_submissions';

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

protected $dateFormat = 'Y-m-d H:i:s.u';
}
9 changes: 6 additions & 3 deletions src/Globals/GlobalSetModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ class GlobalSetModel extends BaseModel

protected $table = 'global_sets';

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

public function getAttribute($key)
{
Expand Down
9 changes: 6 additions & 3 deletions src/Globals/VariablesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ class VariablesModel extends BaseModel

protected $table = 'global_set_variables';

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

public function getAttribute($key)
{
Expand Down
9 changes: 6 additions & 3 deletions src/Revisions/RevisionModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class RevisionModel extends BaseModel

protected $table = 'revisions';

protected $casts = [
'attributes' => 'json',
];
protected function casts(): array
{
return [
'attributes' => 'json',
];
}
}
9 changes: 6 additions & 3 deletions src/Sites/SiteModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ class SiteModel extends BaseModel

protected $table = 'sites';

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

public function getAttribute($key)
{
Expand Down
9 changes: 6 additions & 3 deletions src/Structures/NavModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class NavModel extends BaseModel

protected $table = 'navigations';

protected $casts = [
'settings' => 'json',
];
protected function casts(): array
{
return [
'settings' => 'json',
];
}
}
11 changes: 7 additions & 4 deletions src/Structures/TreeModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ class TreeModel extends BaseModel

protected $table = 'trees';

protected $casts = [
'tree' => 'json',
'settings' => 'json',
];
protected function casts(): array
{
return [
'tree' => 'json',
'settings' => 'json',
];
}
}
11 changes: 7 additions & 4 deletions src/Taxonomies/TaxonomyModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ class TaxonomyModel extends BaseModel

protected $table = 'taxonomies';

protected $casts = [
'settings' => 'json',
'sites' => 'json',
];
protected function casts(): array
{
return [
'settings' => 'json',
'sites' => 'json',
];
}

public function getAttribute($key)
{
Expand Down
9 changes: 6 additions & 3 deletions src/Taxonomies/TermModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ class TermModel extends BaseModel

protected $table = 'taxonomy_terms';

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

public function getAttribute($key)
{
Expand Down
11 changes: 7 additions & 4 deletions src/Tokens/TokenModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ class TokenModel extends BaseModel

protected $table = 'tokens';

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

0 comments on commit bc82a44

Please sign in to comment.