name = $name; $this->items = new MenuCollection($items); } /** * Get the menu's unique key. * * @return string */ public function key() { return md5($this->name.$this->items->reduce(function ($carry, $item) { return $carry.'-'.$item->name; }, '')); } /** * Prepare the menu for JSON serialization. * * @return array */ public function jsonSerialize(): array { $request = app(NovaRequest::class); return [ 'component' => $this->component, 'name' => $this->name, 'items' => $this->items->authorized($request)->withoutEmptyItems()->all(), 'collapsable' => $this->collapsable, 'collapsedByDefault' => $this->collapsedByDefault, 'key' => $this->key(), ]; } }