1

Im trying to define a GET route in laravel with two parameters, but I keep getting a (laravel) 404 page.

my route looks like this:

Route::get('/swapslot/{og}/{new}', 'ItemController@swapSlot')->name('swapslot');

whenever I redirect my users to public/swapslot/*number*/*number* I get a 404 error. I have other routes with 1 parameter, these do work.

6
  • 'swapslot/{og}/new/{new}' try making your URL something like this Commented Apr 30, 2019 at 15:52
  • Elaborate on what the og and new represent, aswell does the function in the controller accept two parameters? Commented Apr 30, 2019 at 16:50
  • Provide your controller function and also how are you making the request. Also, this route is defined in the web.php o api.php. Paste as well the output of php artisan route:list Commented Apr 30, 2019 at 16:59
  • @Miaan the controller function does accept two parameters. OG is the original inventory slot i'm moving an item from, NEW is the new inventory slot i'm moving an item to. Commented Apr 30, 2019 at 17:35
  • @HCK it's defined in web.php. I'm linking the user to public/swapslot/number/number using a javascript function. Cant post the output of that command atm since im @ work. Commented Apr 30, 2019 at 17:40

1 Answer 1

2

The answer to this question is different than I would've expected. Turns out nothing was wrong with my route definition. I was using the eloquent model function findOrFail which sends a 404 HTTP response to the user if it doesn't find the ID it's looking for. Thats why I was getting a 404 page.

Sign up to request clarification or add additional context in comments.

1 Comment

Just a heads up. This is why you need to give more info when asking a question. Like in this case, give the parameters you're sending, the route as well as the controller function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.