In today laravel framework become more and more popular. we almost require all the things do in php application. So in this post i am going to tell you this type of small things like if you have data in object and you want to convert then into json then how you can do this ?
in this example i will know you how to convert std collections objects convert into json. Sometime we have laravel eloquent object and you want in json then you can do it that using toJson().
Laravel provide toJson() that will help to convert object into json of your data So you can simply use like as bellow example:
$users = App\User::all();
$users = $users->toJson();
I hope you found your solution...
You may also like to see this:
Do you like below Tutorials ?
- CRUD Laravel 7.x and 6.x Example
- Image Upload Laravel 7.x and 6.x Tutorial
- Laravel 7.x and 6.x Delete File from public folder example
- How to delete directory in Laravel 7.x and 6.x?
- How to create directory if not exists in Laravel 7.x and 6.x?
- Laravel 7.x and 6.x get all files in directory example
- Laravel 7.x and 6.x check file exists in folder example
- Ajax Autocomplete Textbox in Laravel 7.x and 6.x Example