/**
  * @covers Navigation::sort
  */
 public function testSort()
 {
     $navigation = new Navigation([['title' => 'Page 1', 'priority' => 800], ['title' => 'Page 2', 'priority' => 100, 'pages' => [['title' => 'Page 5', 'priority' => 300], ['title' => 'Page 6', 'priority' => 200]]], ['title' => 'Page 3', 'priority' => 600], ['title' => 'Page 4', 'pages' => [['title' => 'Page 7', 'priority' => 300], ['title' => 'Page 8', 'priority' => 200]]]]);
     $navigation->sort();
     $this->assertEquals(['9cd0e179d2e28222d91e2415d0eb8ade' => ['child' => ['57a047b16059f2bcaaaaaa3cf5e521e0' => ['child' => [], 'hasChild' => false, 'id' => '8e66e59973708ffc406444148008626c', 'title' => 'Page 6', 'icon' => null, 'priority' => 200, 'url' => null, 'path' => ['Page 2', 'Page 6'], 'isActive' => false, 'attributes' => '', 'badge' => null], 'ecdd972f0bcbc358d240ed0767885f42' => ['child' => [], 'hasChild' => false, 'id' => '0d92a8d86d8d60be99f5f3c496192b84', 'title' => 'Page 5', 'icon' => null, 'priority' => 300, 'url' => null, 'path' => ['Page 2', 'Page 5'], 'isActive' => false, 'attributes' => '', 'badge' => null]], 'hasChild' => true, 'id' => '9cd0e179d2e28222d91e2415d0eb8ade', 'title' => 'Page 2', 'icon' => null, 'priority' => 100, 'url' => null, 'path' => ['Page 2'], 'isActive' => false, 'attributes' => ' class="has-child"', 'badge' => null], 'badfcb348b9ac6607ac264d4b9be5964' => ['child' => ['6a6bc5bc485d72522e9a37c80ba127b7' => ['child' => [], 'hasChild' => false, 'id' => '85fca741a01d8b0cb6c87f5fc729ffd0', 'title' => 'Page 8', 'icon' => null, 'priority' => 200, 'url' => null, 'path' => ['Page 4', 'Page 8'], 'isActive' => false, 'attributes' => '', 'badge' => null], '28950881c8300e328f3ee2530eb1a565' => ['child' => [], 'hasChild' => false, 'id' => 'ce1f93d8120197b74c2627b38176b507', 'title' => 'Page 7', 'icon' => null, 'priority' => 300, 'url' => null, 'path' => ['Page 4', 'Page 7'], 'isActive' => false, 'attributes' => '', 'badge' => null]], 'hasChild' => true, 'id' => 'badfcb348b9ac6607ac264d4b9be5964', 'title' => 'Page 4', 'icon' => null, 'priority' => 100, 'url' => null, 'path' => ['Page 4'], 'isActive' => false, 'attributes' => ' class="has-child"', 'badge' => null], 'cdc737b3649adb23c0561b9a9e4295ee' => ['child' => [], 'hasChild' => false, 'id' => 'cdc737b3649adb23c0561b9a9e4295ee', 'title' => 'Page 3', 'icon' => null, 'priority' => 600, 'url' => null, 'path' => ['Page 3'], 'isActive' => false, 'attributes' => '', 'badge' => null], 'dffded34c96876a50a41f3a69c15e186' => ['child' => [], 'hasChild' => false, 'id' => 'dffded34c96876a50a41f3a69c15e186', 'title' => 'Page 1', 'icon' => null, 'priority' => 800, 'url' => null, 'path' => ['Page 1'], 'isActive' => false, 'attributes' => '', 'badge' => null]], $navigation->toArray());
 }
Example #2
0
 /**
  * @return array
  */
 public function toArray()
 {
     if ($this->isActive() and !$this->hasClassProperty($class = config('navigation.class.active', 'active'))) {
         $this->setHtmlAttribute('class', $class);
     }
     if ($this->hasChild() and !$this->hasClassProperty($class = config('navigation.class.has_child', 'has-child'))) {
         $this->setHtmlAttribute('class', $class);
     }
     return ['child' => parent::toArray(), 'hasChild' => $this->hasChild(), 'id' => $this->getId(), 'title' => $this->getTitle(), 'icon' => $this->getIcon(), 'priority' => $this->getPriority(), 'url' => $this->getUrl(), 'path' => $this->getPath(), 'isActive' => $this->isActive(), 'attributes' => $this->htmlAttributesToString(), 'badge' => $this->getBadge()];
 }
 /**
  * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
  */
 public function render()
 {
     return parent::render('cms::navigation.navigation');
 }