Laravel Eloquent / fluent
Its very simple.
$pins = Pin::get();foreach($pins as $p){ $pin[] = $p->to_array();}
or if you want to send out JSON object, try using
$pins = Pin::all();return Response::eloquent($pins);
or if you have an Array to be converted to json output than use
return Response::json(array('name' => 'Batman'));
With Laravel 4 you can just do:
//get all pins from dbpublic function index(){ return Pin::all();}//get specific pin from dbpublic function show($id){ return Pin::find($id);}
that will return your data in Json format
Laravel has a built in to_array()
function so you could do something like this.
$pins = Pin::all();foreach($pins as $pin) { $pin_array = $pin->to_array(); /* Do something with pin array here */}
Hope that helps :D