Laravel 5 json response from controller exampleBy Hardik Savani | May 11, 2016 | | 8508 Viewer | Category : Laravel
If you are working with REST API then you always need to return json data response that way front-end developer can handle it easily. i created bellow controller method in this method i return json array response, that way you can understand very well. laravel 5 provide response() helper and it will help to response of json object. But if you are working on Core PHP then you have to do json_encode before send output. In laravel you can do it easily like this way:
public function getJsonData()
$myArray = ['id'=>1, 'name'=>'HD'];
- Laravel 5 - Authenticate user in NodeJS with socket io using JWT.
- PHP - How to custom file uploading with CKEDITOR?
- PHP MySQL confirmation box before delete record using jquery ajax
- Angularjs Simple Datepicker directive example code with Demo
- Ajax Image Upload using PHP and jQuery Example from scratch
- PHP - How to remove duplicate values from multidimensional array?
- How to get table name from model in Laravel 5?
- How to disable model timestamps in Laravel 5.3?