Questions tagged [laravel-routing]

Routing in Laravel Framework's MVC implementation. Laravel is a free, open source PHP web application framework, and it is released under the MIT license.

laravel-routing is a tag suitable for any questions regarding routing in Laravel's MVC implementation, url handling, or any other matter affecting or affected by routing in Laravel.

2207 questions
3
votes
2 answers

Unable to prepare route [password/reset] for serialization. Another route has already been assigned name [password.request]

I have created a small application in Laravel 8. Everything is fine, but when I wanted to configure the cache I had an error that one route has the same name as another. Reviewing the routes I found duplicate named routes, but since I'm new to…
Edu
  • 33
  • 1
  • 3
3
votes
1 answer

Ways to write Laravel routes

Is there a better way to write these routes? It seems I am repeating the same controller in my route files. Route::post('user', [UserController::class, 'update']); Route::get('user', [UserController::class,…
3
votes
2 answers

Laravel - The POST method is not supported for this route. Supported methods: GET, HEAD

I am trying to add an event on a calendar I have created, however I am getting the following error The POST method is not supported for this route. Supported methods: GET, HEAD I have used the methods @csrf and {{ method_field('PUT') }} to no…
Zak
  • 185
  • 2
  • 4
  • 12
3
votes
4 answers

Form not routing to named route Laravel 5.8

I know I am doing something very basic here but I can't seem to find the issue. My form isn't routing to its named route. Am I naming my route the wrong way? Form
@csrf …
kwestionable
  • 496
  • 2
  • 8
  • 23
3
votes
5 answers

Laravel Route - Check if ID does not exist and show 404

I don't want to show the page if the ID does not exist. How can I check this in my web.php routes in Laravel? I currently have the following route: Route::get('/public/{project_id}', 'ProjectController@public'); How can I do a conditional check to…
ejntaylor
  • 1,900
  • 1
  • 25
  • 43
3
votes
1 answer

Can't set cookie for api route laravel

Doing an service with backend (laravel) and frontend SPA (vue.js, vue-cli 3). I need to make an auth via httpOnly cookie (not localStorage). I use tymondesigns/jwt-auth as api auth package. My environment is: API route:…
Alexxosipov
  • 1,215
  • 4
  • 19
  • 45
3
votes
0 answers

Unit testing middleware in Laravel mocking route with parameter

I am developing a Laravel application. I am now doing Unit testing on the Middleware. I am having a problem with mocking the route. This is my middleware class class CheckIfDepartmentIdPresent { public function handle($request, Closure $next) …
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372
3
votes
2 answers

Setting up named routes within a subdomain group in Laravel 5.7

I have been working on a multi-tenant app and I'm trying to set up the routes in sub-domains according to the documentation:https://laravel.com/docs/5.7/routing#route-group-sub-domain-routing In my web.php route file, I have something like this:…
Erubiel
  • 2,934
  • 14
  • 32
3
votes
2 answers

Understanding Routing in Laravel

I started my project using Laravel, but I don't know how routing works. Example code: Route::get('/', function () { return view('welcome'); }); Where is the get static function? I searched in the Laravel /vendor directory but found nothing.
DeLe
  • 2,442
  • 19
  • 88
  • 133
3
votes
4 answers

Exception Creating New Resource in Laravel Nova - Class 'App\Post' not found

I have a brand new installation of Laravel Nova. The dashboard comes up fine. But when I add a new resource using php artisan nova:resource Post and reload the dashboard, it's throwing an error. When I remove the offending model from Nova folder,…
3
votes
2 answers

How to Use Regex to Route Prefix in Laravel?

Brief: I have a custom routes group with a dynamic prefix: Route::prefix('{nickname}')->group(function () { Route::get('/', function($nickname) { return view('profile'); })->where(['nickname' => '[a-z]+']); Route::get('/edit',…
Andreas Hunter
  • 4,504
  • 11
  • 65
  • 125
3
votes
1 answer

Laravel Route Group Second Parameter?

I updated my project from laravel 5.5.* to 5.5.43... Before the update everything was ok. But after the update, I see a warning message in route/web.php. It says: Required parameter $routes missing. But everything is working fine. Then when I put…
Sand Of Vega
  • 2,297
  • 16
  • 29
3
votes
3 answers

500 Internal Server Error in Ajax call (Laravel)

I am trying to get dependant select items using ajax call. After selecting 'class' it should show the related 'groups'. But, I am getting 500 internal server error on my console. Would someone help me please to get the expected…
Rashed Hasan
  • 3,721
  • 11
  • 40
  • 82
3
votes
1 answer

Laravel. How to define route, based on the Content-Type

Is it possible to create a route, that on the same URL calls different actions in different controllers based on the Content-Type header? I do NOT need this for testing purposes. I need something to use in the api.php file.
D.R.
  • 2,540
  • 3
  • 24
  • 49
3
votes
1 answer

Using a custom middleware redirects me to /home, even if middleware is empty in Laravel

I'm pretty out of any ideas right now. The case is: I have a route for an API-endpoint (working fine, responding JSON etc.). If I now apply the built-in 'auth' middleware to the route, I'm redirected ALWAYS to the /home route. Looks like I'm doing…