If you return Eloquent models or collections directly from your API Controller or even Route file, Laravel will automatically serialize the result to JSON.
Enjoyed This Tip?
Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.
Recent Courses on Laravel Daily
[NEW] Laravel Boost: Deeper Practical Dive
8 lessons
32 min
NativePHP Mobile v4 with SuperNative: Mini-Course
5 lessons
18 min
Laravel 13 Starter Kit Teams and Customizations
10 lessons
33 min