#I got no route with name error when in the web.php there is 1
48 messages · Page 1 of 1 (latest)
Try running php artisan about and see if you've cached your routes. If you've cached them then it won't pick up any new changes, which is why it's quite bad to cache routes locally
Great talk.
@coarse bolt If you ask for help, and get feedback with follow up questions almost immediately, please respond to that.
sry i'm away from my computer
its say the route is not cached
already try to cache the route with artisan route cache
It says they are cached.
yeah just cache it and still show the same error
Well, first of all, clear the cache.
done clear the cache
so how should i proceed?
What does php artisan route:list show?
did not show the job.search
So, what does it show?
It shows your GET /job route is named apply
oh so its conflicted right?
Probably, yes
How would Laravel know which one you'd want to access? http://localhost/job is exactly the same thing as http://localhost/job. How would it be able to differentiate between that?
oh okay thanks
One thing you can do is have a GET and POST to the same URL work differently. I often use that for an operation which needs user input (maybe a confirmation screen). I put the confirmation/input from on a Route::get('/xyz') and then have a Route::post('/xyz') to receive the user input and perform the action.
so can i put the route method to the other page with nothing on then just pass it to the server then redirect it back? as the controller do redirect the method?
No - create two routes with the same URL, but point each to a different Controller method
Route::get('/my-url', [App\Http\Controllers\MyController::class, 'confirmAction'])
->name('my.route.name.confirm');
Route::post('/my-url', [App\Http\Controllers\MyController::class, 'doAction'])
->name('my.route.name.do');
It's a similar approach to that used by Laravel's resource controllers: https://laravel.com/docs/10.x/controllers#resource-controllers The index and store routes use the same URI, as do show/update/destroy, but use different HTTP Verbs to differentiate between them
so lets say i got a button in a page that does 1 thing and need a route and another button do another how do I comply with the route?
in the same page
i mean like i store a data then i go refresh the data in the same page does that mean i need another page?
I'm not sure I follow.
You need a route for every action you want your user to take. So:
1 route to load your page
1 route for button #1's action
1 route for button #2's action
I'm not sure about the refresh part though
so lets say i got a refresh the data button and 1 set an update button and 1 say insert button
that means i got 3 button or route in 1 page right?
so is it better that i make 3 separate each button to another page or still just in a single page?
You can have all the buttons on one page, for sure. But each button would call a different route as the code they need to trigger will be different.
Your page would be loaded by one route, and then the buttons call other routes depending on what they need to do.
Your 'insert' button, for example - if the form the user fills in is on your first page, then that button would post the data to a route. But, your insert button could, if you needed, link to another page with your data-entry form (a different route), on which there would be a "submit" button which posted the data to a specific route.
You essentially need to map out the actions you need a user to take and how the pages will be designed, and work out what server calls you'll be making. Each call will need a route, whether it's loading data or receiving / processing it.
But if you have list of records (an index), and the ability to update and insert new records, take a look at the resource controllers I linked to above - that gives you a framework for exactly those sorts of situations (known as CRUD)
so as long as it did not use the same route type with one another its ok to have multiple route in 1 page?
Perhaps it's useful to circle back to the beginning; what are you trying to do?
Routes and pages are very different things. A page is a display (a View) - a route might return a view/page. But that page will likely contain many links / buttons / elements which call other routes.
so i got the error have 2 get in a single page like that 1 for applying the job at the job search
and it did not read the other
cause it already read 1 route
@coarse bolt Is this solved or not? Because the thread has the “solved” tag applied.
oh its solved when i change the path for the get but i still dun get it in general so i ask the follow up question