#I got no route with name error when in the web.php there is 1

48 messages · Page 1 of 1 (latest)

coarse bolt
#

so this is the route in web.php

Route::get('/job', [JobController::class,'search'])->name('jobs.search');

and the error is in the picture

lone hemlock
#

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

lone hemlock
#

Great talk.

grave dirge
#

@coarse bolt If you ask for help, and get feedback with follow up questions almost immediately, please respond to that.

coarse bolt
#

sry i'm away from my computer

#

its say the route is not cached

#

already try to cache the route with artisan route cache

lone hemlock
#

It says they are cached.

coarse bolt
#

yeah just cache it and still show the same error

lone hemlock
#

Well, first of all, clear the cache.

coarse bolt
#

done clear the cache

coarse bolt
#

so how should i proceed?

lone hemlock
#

What does php artisan route:list show?

coarse bolt
#

did not show the job.search

lone hemlock
#

So, what does it show?

coarse bolt
#

its show this

lone hemlock
#

It shows your GET /job route is named apply

coarse bolt
#

oh so its conflicted right?

lone hemlock
#

Probably, yes

coarse bolt
#

yeah

#

so in a route we cant have 2 same method?

#

in 1 page?

lone hemlock
#

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?

coarse bolt
#

oh okay thanks

bleak girder
#

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.

coarse bolt
#

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?

bleak girder
#

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');
coarse bolt
#

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?

bleak girder
#

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

coarse bolt
#

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?

bleak girder
#

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)

coarse bolt
#

so as long as it did not use the same route type with one another its ok to have multiple route in 1 page?

lone hemlock
#

Perhaps it's useful to circle back to the beginning; what are you trying to do?

bleak girder
#

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.

coarse bolt
#

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

tepid topaz
#

@coarse bolt Is this solved or not? Because the thread has the “solved” tag applied.

coarse bolt
#

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