V
V
Vladimir Singhtlov2018-08-14 17:54:31
Laravel
Vladimir Singhtlov, 2018-08-14 17:54:31

Why is Request giving out the old route when making an ajax request?

Suppose there is a section1 in it controllers and for each role methods are cardinally separated, I decided to use middleware to call the desired controller from the role folder,
we take the priority role app ()-> call () controller, if not in the default one.
Http
- Controllers
- - Section1
- - - Admin
- - - - IndexController
- - - - MessageController
- - - IndexController
- - - MessageController Sample
routes

Route::prefix('section')
                    ->namespace('Section')
                    ->as('section.')->group(function () {
                        Route::get('/', '[email protected]')->name('index');

                        Route::prefix('messages')->as('messages.')->group(function () {
                            Route::post('/', '[email protected]')->name('index');
                            Route::put('/', '[email protected]')->name('store');
                            Route::prefix('{message}')->group(function () {
                                Route::delete('/', '[email protected]')->name('destroy');
                            });
                        });
                    });

At the moment, the middleware is just dd
public function handle($request, Closure $next)
    {
        dd($request->route());

When requested from /section to /section/message/
axios({
                    method: 'post',
                    url: '/section/messages',
                    data: {}
                });

I get section.index route and not section.messages.index

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d-virt, 2018-08-14
@d-virt

Move Middleware here:
And you will be correctdd($request->route());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question