Skip to main content

Parking history page

Premium
7 min read

Now when we stop parking it just disappears from the active parking list. This was planned to separate parking orders into active and history categories so they don't get in the way of each other and are more convenient.

Let's implement the parking history list in this lesson.

Parking history

1. Extend Store

Extend parking store src/stores/parking.js...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (31 h 16 min)

You also get:

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

Already a member? Login here

Comments & Discussion

K
Karolis ✓ Link copied!

For those who need parkings/history API:

api.php:

Route::get('parking/history', [ParkingController::class, 'stoppedParkings']);

ParkingController.php:

public function stoppedParkings()
{
    return ParkingResource::collection(Parking::with('vehicle', 'zone')->stopped()->get());
}
H
haritjahjo ✓ Link copied!

I get error status 500 to view parking from menu history. I think caused by this function history from previous course (ParkingController.php).

public function history()
	{
		$stoppedParkings = Parking::stopped()
			->with(['vehicle' => fn ($q) => $q->withTrashed()])
			->latest('stoptime')
			->get();
		return ParkingResource::collection($stoppedParkings);
}

I copied history function from github previous course (app/Http/Controllers/Api/V1/ParkingController.php). How to fix this? Regards.

DL
David Lun ✓ Link copied!

hi, what does 500 response say?

H
haritjahjo ✓ Link copied!

Solved. I missed to add

use SoftDeletes();

in Vehicle model class.