According to the documentaion[http://ift.tt/1EAeK0g] all
and get
methods retrieve results as an instance of Collection, which can be iterate through like
foreach ($flights as $flight) {
echo $flight->name;
}
In my case only all
method is returning instance of collection,not the get
method because I can't iterate through result as above way and throws error: Undefined property: Illuminate\Database\Eloquent\Collection::$name
. If I only echo $flight
then it prints [{"id":3,"name":"KingFisher","created_at":"2015-09-01 16:09:09","updated_at":"2015-09-01 16:09:09"}]
, which is a json format.From this[http://ift.tt/1L1Z5mV] page I tried json_decode($flights, true);
and new \Illuminate\Support\Collection(json_decode($flights, true))
but both returning same json format and I can't iterate throught them as collection. Any idea?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1EAeH4B
via IFTTT
Aucun commentaire:
Enregistrer un commentaire