AppServiceProvider.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. 'App\Http\Middleware\CsrfMiddleware',
  30. ];
  31. /**
  32. * Build the application stack based on the provider properties.
  33. *
  34. * @return void
  35. */
  36. public function stack()
  37. {
  38. $this->app->stack(function(Stack $stack, Router $router)
  39. {
  40. return $stack
  41. ->middleware($this->stack)->then(function($request) use ($router)
  42. {
  43. return $router->dispatch($request);
  44. });
  45. });
  46. }
  47. }