dimanche 30 septembre 2018

Laravel insert and update to JSON not working

Can't figure out why JSON field is being ignored.

This one doesn't work:

Registries::create([
    'nr' => $old_document->no,
    'metas->name' => 'r01',
]);

In model I have set:

protected $casts = [
        'metas' => 'array',
    ];

And:

protected $fillable = [
        'nr',
        'metas'
    ];

I think the problem is in attributes casting, because this one is working:

Registries::create([
    'nr' => $old_document->no,
    'metas' => json_encode(['name'=>'r01']),
]);

I'm not getting any errors just JSON column stays empty.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Rd94By
via IFTTT

Aucun commentaire:

Enregistrer un commentaire