My Laravel links keep breaking each time I restart my local server
So, I am using Laravel 9 and my links keep breaking each time I reload the page or when I restart the server
For example
127.0.0.1:8000/cars/1/edit
will become 127.0.0.1:8000/cars/cars/1/edit
next time I click it.
I have searched for a solution and stumbled upon this On every click link changes in blade view
But the problem is that the guy that asked the question is using named routes from web.php route
I, on the other hand, am using resource routes ( I do not know what to call them = Route::resource('/cars', CarsController::class);)
For that reason, I’m finding it difficult to implement the route() solution proposed as his had a named route name
The href I want to make changes to looks like this. I am using resources routes in web.php
<a href="cars/{{ $car['id'] }}/edit">Edit →</a>
3
Answers
try this :
You should use the
route()
helper.They are named to their corresponding method. since you are using route resource only the seven below will work
You can try something like this:
Or: