Courses

Re-creating Booking.com API with Laravel and PHPUnit

We ended up the previous lesson by returning a huge JSON from the property search results. Let's spend this lesson optimizing it and showing only the data that we really need to return.


Goals of This Lesson

  • Transform the returned data using Eloquent API Resources
  • Create Accessors to show Addresses and Beds list in a human-friendly way
  • Fix search results order/limit: showing only ONE apartment per property

By the end of this lesson, we will have this nice JSON structure in search results:

Property search beds


Shorter JSON: Eloquent API Resources

A quick reminder of how it looks now.

Endpoint: /api/search?city_id=1&adults=2&children=1

Result JSON:...

This lesson is only for Premium Members.
Want to access all lessons of this course?

You also get:

  • 68 courses (1183 lessons, 43 h 18 min total)
  • Premium tutorials
  • Access to repositories
  • Private Discord