MenuCacheCommand.php 754 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Dcat\Admin\Console;
  3. use Illuminate\Console\Command;
  4. class MenuCacheCommand extends Command
  5. {
  6. /**
  7. * The console command name.
  8. *
  9. * @var string
  10. */
  11. protected $signature = 'admin:menu-cache';
  12. /**
  13. * The console command description.
  14. *
  15. * @var string
  16. */
  17. protected $description = 'Flush the menu cache';
  18. /**
  19. * Execute the console command.
  20. *
  21. * @return void
  22. */
  23. public function handle()
  24. {
  25. $menuModel = config('admin.database.menu_model');
  26. $menuModel = new $menuModel();
  27. $menuModel->flushCache();
  28. $this->info('Menu cache cleared!');
  29. $menuModel->allNodes();
  30. $this->info('Menu cached successfully!');
  31. }
  32. }