lepikhinb / momentum-modal

MIT License
442 stars 26 forks source link

baseRoute method does not respect the middleware #36

Closed mahbubahmed closed 1 year ago

mahbubahmed commented 1 year ago

My route.php look like the following. Each time the URLs are hit the ModifyParameters middleware is supposed to be executed.

Route::group(['middleware' => [ModifyParameters::class]], function () {
    Route::resource('users', UserController::class);
});

My UserController looks like the following:

function index()
{
  return inertia('Customers/Index', []);
}

// runs when I hit mydomain.com/users/create
function create()
{
   return Inertia::modal('Users/Create', [])
    ->baseRoute('users.index');
}

Everything works perfectly except when the URL "mydomain.com/users/create" is hit directly from the address bar of the browser.

When the create method is hit, the Inertia::modal method runs the baseRoute method to render the page in the "index" method of the controller, however during the process it does not execute the middleware "ModifyParameters".

It respects the __construct method of the controller, but is there any way to make it execute the middleware defined in the route?

bretto36 commented 9 months ago

@mahbubahmed Did you manage to get around this at all?