Black Friday: coupon FRIDAY24 for 40% off Yearly/Lifetime membership! Read more here
Courses

Build Laravel API for Car Parking App: Step-By-Step

Of course, users need to know how much they would pay for parking. It should happen in three phases:

  • Before parking - when getting the list of zones (done)
  • During parking - when getting the parking by ID (not done yet)
  • After parking - as a result of the stopping function (not done yet)

As I mentioned in the very beginning, we won't cover the payments themselves in this tutorial, we only take care of the calculations.

So, we need to create some function to calculate the current price by zone and duration, and then save that price in the parkings.total_price when the parking is stopped.

For that, let's create a separate Service class with a method to calculate the price. In Laravel, there's no Artisan command make:service, so we just create this file manually in the IDE...

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

You also get:

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