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 ?
- How to File Upload in PHP Laravel 8?
- Laravel 5 - An access token is required to delete a video - issue
- Laravel 5.5 - POST <target url> 419 (unknown status) - can't ajax post data
- Laravel 7.x and 6.x get last query log example
- Bootstrap Timepicker in Angular Example
- Laravel 8 Livewire Datatables Example
- Laravel Collection Group by Column Example
- PHP Disable Submit Button After Click Example
- How to convert base64 to image and save it using PHP?
- Allow only Numbers in Input Field React JS Example
- Laravel 5.5 create zip archive file and download example
- Livewire CRUD Laravel 7 Example