AppServiceProvider.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\Middleware\Guard',
  25. 'Illuminate\Cookie\Middleware\Queue',
  26. 'Illuminate\Session\Middleware\Reader',
  27. 'Illuminate\Session\Middleware\Writer',
  28. 'Illuminate\View\Middleware\ErrorBinder',
  29. ];
  30. /**
  31. * Build the application stack based on the provider properties.
  32. *
  33. * @return void
  34. */
  35. public function stack()
  36. {
  37. $this->app->stack(function(Stack $stack, Router $router)
  38. {
  39. return $stack
  40. ->middleware($this->stack)->then(function($request) use ($router)
  41. {
  42. return $router->dispatch($request);
  43. });
  44. });
  45. }
  46. }