S
S
Sergei Makhlenko2020-10-28 14:54:09
Laravel
Sergei Makhlenko, 2020-10-28 14:54:09

Routing not working as expected in Laravel?

Hello, I can’t understand how routing works in Laravel (latest version 8, maybe in other versions as well).

Route::prefix('admin')->name('admin.')->middleware('auth')->group(function()
{
    /* admin home page */
    Route::get('/', [\App\Http\Controllers\Admin\Pages\Index::class, 'list'])->name('home');
});

Below is the following structure:
Route::group(['prefix' => '{language}'], function() {
    Auth::routes();
    Route::get('/{slug?}', [\App\Http\Controllers\Page::class, 'index'])->name('page');
});

When opening /admin , although in theory, this group should not fall under another.
Missing required parameters for [Route: page] [URI: {language}/{slug?}]

Added \App\Http\Middleware\Locale::class to $middlewareGroups in `app/Http/Kernel.php` to set the system language, depending on the link.

As I understand laravel should look for matches. But why is the superior admin ignored, and how to get around this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2020-10-28
@weblive

But why is the superior admin ignored, and how to get around this.
Because he is superior. It's easy to get around - make it downstream.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question