framework icon indicating copy to clipboard operation
framework copied to clipboard

Resource Controller registration causes non-resource routes to be ignored

Open bluesheep100 opened this issue 1 month ago • 11 comments

Laravel Version

12.38.1

PHP Version

8.3.27

Database Driver & Version

SQLite 3.37.2

Description

Routes using a resources prefix (e.g. /users for the User model) placed after a Route::resource() call seem to be ignored, but still shown in the list when running php artisan route:list.

Steps To Reproduce

Discovered on v12.36.1, verified on v12.38.1

Tested on a brand new starter kit free application:

  • laravel new routetester
  • No starter kit
  • Pest
  • SQLite database

Test case setup:

  • Create a resource controller: php artisan make:controller ExampleController -r
  • Add return to_route('welcome'); to the index() method

Then add this method to the controller:

public function test()
{
    return to_route('welcome');
}

And the following route definitions to routes/web.php:

Route::resource('examples', ExampleController::class);
Route::get('/examples/test', [ExampleController::class, 'test'])->name('examples.test');

Run php artisan serve and visit localhost:8000/examples, which should display the welcome page.

Visiting localhost:8000/examples/test however, gives a blank white page, with 200 OK as the status code. If the order of the route definitions are switched, the welcome page is displayed. If using a DELETE request instead of GET, this issue seems to end in a 404 Not Found.

bluesheep100 avatar Nov 13 '25 13:11 bluesheep100