MenuShow.php 702 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Distributor\Actions;
  3. use App\Models\SiteMenu;
  4. use Dcat\Admin\Tree\RowAction;
  5. class MenuShow extends RowAction
  6. {
  7. public function handle()
  8. {
  9. $key = $this->getKey();
  10. $menu = SiteMenu::where('id', $key)->first();
  11. $menu->show = $menu->show ? 0 : 1;
  12. $menu->save();
  13. $location = $menu->menu_location;
  14. return $this
  15. ->response()
  16. ->success(trans('admin.update_succeeded'))
  17. ->location('site-menu?location='.$location);
  18. }
  19. public function title()
  20. {
  21. $icon = $this->getRow()->show ? 'icon-eye-off' : 'icon-eye';
  22. return "&nbsp;<i class='feather $icon'></i>&nbsp;";
  23. }
  24. }