MenuShow.php 641 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. return $this
  14. ->response()
  15. ->success(trans('admin.update_succeeded'))
  16. ->location('site-menu');
  17. }
  18. public function title()
  19. {
  20. $icon = $this->getRow()->show ? 'icon-eye-off' : 'icon-eye';
  21. return "&nbsp;<i class='feather $icon'></i>&nbsp;";
  22. }
  23. }