Support the ongoing development of Laravel.io →
Requests IOC Packages
Last updated 2 years ago.
0

I have not found the function to add/create a middleware group, but these are the other ways I found to add middleware in a service provider.


public function boot( Illuminate\Routing\Router $router, \App\Http\Kernel\Kernel $kernel) {

	// Add a new middleware to beginning of the stack if it does not already exist.
	$kernel->prependMiddleware(\path\to\custom\middleware\file::class)

	// Add a new middleware to end of the stack if it does not already exist.
	$kernel->pushMiddleware(\path\to\custom\middleware\file::class)

	// Get or set the middlewares attached to the route.
	$router->middleware(\path\to\custom\middleware\file::class)

}
Last updated 8 years ago.
0

TerrePorter said:

I have not found the function to add/create a middleware group, but these are the other ways I found to add middleware in a service provider.


public function boot( Illuminate\Routing\Router $router, \App\Http\Kernel\Kernel $kernel) {

  // Add a new middleware to beginning of the stack if it does not already exist.
  $kernel->prependMiddleware(\path\to\custom\middleware\file::class)

  // Add a new middleware to end of the stack if it does not already exist.
  $kernel->pushMiddleware(\path\to\custom\middleware\file::class)

  // Get or set the middlewares attached to the route.
  $router->middleware(\path\to\custom\middleware\file::class)

}

Thank you for your replay. I found the solutions too, but it seems I need some workaround about it or wait till middleware group register functions will appear in router class.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

m4nt4s m4nt4s Joined 3 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.