Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Parking list and Stop parking

Premium
6 min read

In this lesson, we will display an active parking list with a stop button to end parking.

Active parkings list

1. Two new methods

Let's add two more methods into src/stores/parking.js...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (29 h 14 min)

You also get:

54 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

ZA
Zain Amin ✓ Link copied!

I noticed that the API for the parking list is missing. (https://laraveldaily.com/lesson/build-laravel-api-step-by-step/start-stop-parking)

HN
Huy Nguyen ✓ Link copied!

You can add this route to api.php file, this is in middleware

Route::middleware('auth:sanctum')->group(function () {
...
 Route::get('parkings', [\App\Http\Controllers\Api\V1\ParkingController::class, 'index'])->name('parkings.index');
 ...
 })

Then add this action to ParkingController

    public function index(Request $request)
   {
       return new ResponseSuccess(ParkingResource::collection(Parking::with('vehicle')->whereNull('stop_time')->get()));
   }
K
Karolis ✓ Link copied!

We already have active scope in the Parking model. Another way to write this method could be:

public function index()
{
    return ParkingResource::collection(Parking::with('vehicle', 'zone')->active()->get());
}

Do not forget to put zone model for the zone name and price.

NS
Ngozi Stephen Onyemauche ✓ Link copied!

Pls my active parking list is not showing with a stop button i don't know what might be the problem

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.