Level 102
Show the controller code as well. Maybe you arent using eloquent.
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Eloquent:
protected $fillable = [
'name',
'nickname',
'server',
];
protected $hidden = [
'email',
'token'
];
protected $casts = [
'server' => 'array'
];
migration:
$table->json('server');
And API return me this:
"server": "[1, 5]",
How i can correctly cast it to array?
@aurorame There you go. Laravel already runs json_encode, so you are encoding it twice
$user = User::create([
'server' => [1, 5]
]);
Please or to participate in this conversation.