Skip to content

A bug was detected when using the prefix method without group method #49039

Closed
@andrey-helldar

Description

@andrey-helldar

Laravel Version

10.32.1

PHP Version

8.2.12

Database Driver & Version

No response

Description

When using the prefix method on routes that are not groups, it incorrectly generates the destination URL.

It should be like this:

POST api/orders/some ..... orders.index › OrderController@index
POST api/webhook/some ............. webhook › WebhookController

But this option is displayed instead:

POST api/orders/some ..... orders.index › OrderController@index
POST webhook/api/some ............. webhook › WebhookController

Steps To Reproduce

  1. Create a controllers:
    php artisan make:controller OrderController
    php artisan make:controller WebhookController -i
  2. Create routes:
    use App\Http\Controllers\OrderController;
    use App\Http\Controllers\WebhookController;
    
    app('router')
        ->name('orders.')
        ->prefix('orders')
        ->controller(OrderController::class)
        ->group(static function () {
            app('router')->post('some', 'index')->name('index');
        });
    
    app('router')
        ->name('webhook')
        ->prefix('webhook')
        ->post('some', WebhookController::class);
  3. Execute the console command:
    php artisan route:list
routes.bug.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions