Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Auth/Models/Preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ class Preferences extends Model
protected static $cache = [];

/**
* @var array jsonable attribute names that are json encoded and decoded from the database
* @var array casts attribute types to convert automatically
*/
protected $jsonable = ['value'];
protected $casts = [
'value' => 'array'
];

/**
* @var \October\Rain\Auth\Models\User userContext is the user that owns the preferences
Expand Down
6 changes: 4 additions & 2 deletions src/Auth/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ class Role extends Model
];

/**
* @var array jsonable attribute names that are json encoded and decoded from the database
* @var array casts attribute types to convert automatically
*/
protected $jsonable = ['permissions'];
protected $casts = [
'permissions' => 'array'
];

/**
* @var array allowedPermissionsValues
Expand Down
6 changes: 4 additions & 2 deletions src/Auth/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ class User extends Model implements Authenticatable
public $customMessages = [];

/**
* @var array jsonable attribute names that are json encoded and decoded from the database
* @var array casts attribute types to convert automatically
*/
protected $jsonable = ['permissions'];
protected $casts = [
'permissions' => 'array'
];

/**
* allowedPermissionsValues
Expand Down
89 changes: 0 additions & 89 deletions src/Database/Concerns/HasJsonable.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Database/ExpandoModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(array $attributes = [])
// Process attributes last for traits with attribute modifiers
$this->bindEvent('model.beforeSaveDone', [$this, 'expandoBeforeSaveDone'], -1);

$this->addJsonable($this->expandoColumn);
$this->addCasts([$this->expandoColumn => 'array']);
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Database/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
class Model extends EloquentModel
{
use Concerns\HasEvents;
use Concerns\HasJsonable;
use Concerns\HasAttributes;
use Concerns\HasReplication;
use Concerns\HasRelationships;
Expand Down
6 changes: 4 additions & 2 deletions src/Database/Models/DeferredBinding.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ class DeferredBinding extends Model
public $table = 'deferred_bindings';

/**
* @var array jsonable attribute names that are json encoded and decoded from the database
* @var array casts attribute types to convert automatically
*/
protected $jsonable = ['pivot_data'];
protected $casts = [
'pivot_data' => 'array'
];

/**
* @var array nullable attribute names which should be set to null when empty
Expand Down
5 changes: 0 additions & 5 deletions src/Database/Traits/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,6 @@ public function validate($rules = null, $customMessages = null, $attributeNames
if (!empty($rules)) {
$data = $this->getValidationAttributes();

// Decode jsonable attribute values
foreach ($this->getJsonable() as $jsonable) {
$data[$jsonable] = $this->getAttribute($jsonable);
}

// Add relation values, if specified.
foreach ($rules as $attribute => $rule) {
if (!$this->hasRelation($attribute) || array_key_exists($attribute, $data)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Scaffold/Console/contentfield/contentfield.stub
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class {{studly_name}} extends ContentFieldBase
*/
public function extendModelObject($model)
{
$model->addJsonable($this->fieldName);
$model->addCasts([$this->fieldName => 'array']);
}

/**
Expand Down
Loading