return Response::json(array(
'status' => 200,
'posts' => $post->toArray()
), 200);
Using the code above I returned data in json format.
I have seen other api's that return json giving it back in formatted view.
Like:
http://api.steampowered.com/ISteamNews/GetNewsForApp/v0002/?appid=440&count=3&maxlength=300&format=json
But mine is returning it in one line. How do I generate the json in a formatted way with laravel?
update
I cannot test the code yet until I tomorrow. So I'll accept the answer tom.
But this is the api
http://laravel.com/api/class-Illuminate.Support.Facades.Response.html
and the parameters are,
$data
$status
$headers
update
Actually I modified the response class of illuminate to have that constant.