When fetching all rows from an Eloquent Model :
$pin = Pin::all();
I get an array that looks like:
array(2) {
[0]=>
object(Pin)#36 (5) {
["attributes"]=>
array(9) {
["id"]=>
string(1) "2"
["creator"]=>
string(1) "1"
["original"]=>
array(9) {
["id"]=>
string(1) "2"
["creator"]=>
string(1) "1"
}
["relationships"]=>
array(0) {
}
["exists"]=>
bool(true)
["includes"]=>
array(0) {
}
}
}
As when I use Fluent instead:
$pin = DB::table('pins')->get();
I get as a plain array without the “Attribute”, “Orginial”, “realtionships” .. indexes.
How can I use Eloquent so that it returns a Plain Array like FLuent does?
Its very simple.
or if you want to send out JSON object, try using
or if you have an Array to be converted to json output than use