Courses

Re-creating Booking.com API with Laravel and PHPUnit

Search for Property by City or GeoObject

Now, that we have properties in our database, let's start building the search.

Booking.com search by geographical object


Goals of This Lesson

  • Create API endpoint (Route + Controller) for searching the properties by city, country, or geographical object
  • Write PHPUnit tests for all those cases

By the end of this lesson, we will see these tests passing in Terminal:

Property search test


Creating Controller and Route

In later lessons, we will have more parameters for the search, but we have to start somewhere. So, for starters, we will try these criteria:

  • By city
  • By country
  • Close to a geographical object (by its latitude/longitude)

Let's build the controller and method for this...

The full lesson is only for Premium Members.
Want to access all 23 lessons of this course? (224 min read)

You also get:

  • 69 courses (majority in latest Laravel 11)
  • Premium tutorials
  • Access to repositories
  • Private Discord