Server IP : 66.29.132.124 / Your IP : 18.119.253.198 Web Server : LiteSpeed System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : wavevlvu ( 1524) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/wavevlvu/book24.ng/modules/Core/Models/ |
Upload File : |
<?php namespace Modules\Core\Models; use App\BaseModel; use Illuminate\Support\Facades\Cache; class Menu extends BaseModel { protected $table = 'core_menus'; protected static $currentMenuItem = false; public $lastIndex = 0; public function getItemsJsonAttribute() { $items = json_decode($this->items, true); return $this->filterMenuItems($items,$this->lastIndex); } protected function filterMenuItems($items,&$i = 0){ $res = []; if (!empty($items)) { foreach ($items as $k => $item) { $item['_id'] = $i; $class = $item['item_model'] ?? 'custom'; $item['model_name'] = ''; $item['open'] = false; if ($class == 'custom') { $item['model_name'] = __('Custom'); } if (method_exists($class, 'getAsMenuItem') and !empty($item['id'])) { $origin = call_user_func([ $class, 'getAsMenuItem' ], $item['id']); if (!empty($origin)) { $item['origin_name'] = $origin->name; $item['origin_edit_url'] = $origin->edit_url; } else { $item['is_removed'] = true; } } else { $item['is_removed'] = true; } if (method_exists($class, 'getModelName')) { $item['model_name'] = call_user_func([ $class, 'getModelName' ]); } if(!empty($item['children'])){ $item['children'] = $this->filterMenuItems($item['children'],$i); } unset($item['_id']); if(isset($item['open'])) unset($item['open']); if(!isset($item['_open'])) $item['_open'] = false; $res[] = $item; $i++; } } return $res; } public function save(array $options = []) { $res = parent::save($options); // TODO: Change the autogenerated stub if($res){ Cache::forget($this->cacheKey().':'.$this->id); } return $res; } public function saveOriginOrTranslation($locale = false, $saveSeo = true) { $res = parent::saveOriginOrTranslation($locale, $saveSeo); // TODO: Change the autogenerated stub Cache::forget($this->cacheKey().':'.$this->id); return $res; } }