Bootstrap.php 745 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Dcat\Admin\Middleware;
  3. use Dcat\Admin\Admin;
  4. use Illuminate\Http\Request;
  5. class Bootstrap
  6. {
  7. public function handle(Request $request, \Closure $next)
  8. {
  9. $this->includeBootstrapFile();
  10. $this->setupScript();
  11. $this->fireEvents();
  12. return $next($request);
  13. }
  14. protected function includeBootstrapFile()
  15. {
  16. if (is_file($bootstrap = admin_path('bootstrap.php'))) {
  17. require $bootstrap;
  18. }
  19. }
  20. protected function setupScript()
  21. {
  22. $token = csrf_token();
  23. Admin::script("Dcat.token = \"$token\";console.log(56565656)");
  24. }
  25. protected function fireEvents()
  26. {
  27. Admin::callBooting();
  28. Admin::callBooted();
  29. }
  30. }