Last active
August 5, 2016 13:20
-
-
Save icemancast/11293902 to your computer and use it in GitHub Desktop.
Laravel return json from url
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create an action for the route | |
public function postToJson() | |
{ | |
// Query here for json you want to return | |
$post = Post::all(); | |
// Send to json response | |
return Response::json($post->toArray(), 200); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create route for json file | |
Route::get('/posts.json', 'PostsController@postToJson'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment