AppServiceProvider.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php namespace App\Providers;
  2. use Illuminate\Routing\Router;
  3. use Illuminate\Routing\Stack\Builder as Stack;
  4. use Illuminate\Foundation\Support\Providers\AppServiceProvider as ServiceProvider;
  5. class AppServiceProvider extends ServiceProvider {
  6. /**
  7. * All of the application's route middleware keys.
  8. *
  9. * @var array
  10. */
  11. protected $middleware = [
  12. 'auth' => 'App\Http\Middleware\AuthMiddleware',
  13. 'auth.basic' => 'App\Http\Middleware\BasicAuthMiddleware',
  14. 'csrf' => 'App\Http\Middleware\CsrfMiddleware',
  15. 'guest' => 'App\Http\Middleware\GuestMiddleware',
  16. ];
  17. /**
  18. * The application's middleware stack.
  19. *
  20. * @var array
  21. */
  22. protected $stack = [
  23. 'App\Http\Middleware\MaintenanceMiddleware',
  24. 'Illuminate\Cookie\Guard',
  25. 'Illuminate\Cookie\Queue',
  26. 'Illuminate\Session\Middleware\Reader',
  27. 'Illuminate\Session\Middleware\Writer',
  28. ];
  29. /**
  30. * Build the application stack based on the provider properties.
  31. *
  32. * @return void
  33. */
  34. public function stack()
  35. {
  36. $this->app->stack(function(Stack $stack, Router $router)
  37. {
  38. return $stack
  39. ->middleware($this->stack)->then(function($request) use ($router)
  40. {
  41. return $router->dispatch($request);
  42. });
  43. });
  44. }
  45. }