Models with Enum casts are creating duplicate records.
agrism opened this issue · 0 comments
agrism commented
When updating a model in the Redis database, a new record is created instead of updating the existing one, only when a field cast as an Enum is modified.
Model:
<?php
namespace App\Models;
use Alvin0\RedisModel\Model;
use App\Enums\StatusEnum;
/**
* @property string $id
* @property StatusEnum $status
*/
class MyEnumModel extends Model
{
protected $primaryKey = 'id';
protected $subKeys = [
'status',
'msg'
];
protected $fillable = [
'status',
'msg'
];
protected $casts = [
'status' => StatusEnum::class,
'msg' => 'string'
];
public $incrementing = true;
protected $table = "my_enum_models";
}
Temporary solution is to make $subKeys
empty
protected $subKeys = [];