FleetCart/Modules/Menu/MegaMenu/MegaMenu.php

35 lines
768 B
PHP
Raw Normal View History

2023-06-11 12:14:03 +00:00
<?php
namespace Modules\Menu\MegaMenu;
use Illuminate\Support\Facades\Cache;
use Modules\Menu\Entities\Menu as MenuModel;
class MegaMenu
{
private $menuId;
2023-12-03 14:07:47 +00:00
2023-06-11 12:14:03 +00:00
public function __construct($menuId)
{
$this->menuId = $menuId;
}
2023-12-03 14:07:47 +00:00
2023-06-11 12:14:03 +00:00
public function menus()
{
return Cache::tags(['mega_menu', 'menu_items', 'pages', 'categories'])
->rememberForever(md5("mega_menu.{$this->menuId}:" . locale()), function () {
return $this->getMenus()->map(function ($menu) {
return new Menu($menu);
});
});
}
2023-12-03 14:07:47 +00:00
2023-06-11 12:14:03 +00:00
private function getMenus()
{
return MenuModel::for($this->menuId)->where('menu_id', $this->menuId);
}
}