lundi 4 septembre 2017

Access json object column in Eloquent collections?

A table column in my database is saved as json type. I want to display a value in the saved json object on my blade templates but I'm unsure how.

Let's say I have $table->json('meta') in my table schema for Newsletter model, with meta column having e.g. {"foo": "bar"} as value.

How would I retrieve something like $newsletter->meta->foo? Since $newsletter->meta returns string instead of json object by default on Laravel 5.5 requiring a trivial json_decode to convert it. Does Laravel have built in functionality to automatically parse json type columns?



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

Aucun commentaire:

Enregistrer un commentaire