jeudi 13 mars 2014

Displaying JSON variable value in Laravel


Vote count:

0




I have received this, in my recent Laravel 4.1 project which I believe a JSON return,



{"id":5,"owner":"2","message":"What a wonderful shoot today in Belgium!","post_at":"2","created_at":"2014-02-25 15:05:50","updated_at":"2014-02-25 19:05:50"}


however I usually able to display it like this:



echo $post->id;


but somehow instead of "5", it's returning nothing. but when I converted to array using $post->toArray(); and trying to view using echo $post['id']; it successfully returns "5".


What's the best way to be able to return it's value using echo $post->id;? I also have tried to ensure the variable as JSON by using $post->toJSON(); but it still returns empty.



asked 3 mins ago






Aucun commentaire:

Enregistrer un commentaire