@@ -75,7 +75,7 @@ |
||
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * @param string $name |
| 78 | - * @param mixed $value |
|
| 78 | + * @param string $value |
|
| 79 | 79 | * @return $this |
| 80 | 80 | */ |
| 81 | 81 | public function put($name, $value) |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $builder = $this->builderFactory(); |
| 35 | 35 | |
| 36 | 36 | $item = $builder->add('index', 'Index', url('/'), ['class' => 'main-menu'], ['class' => 'link'], |
| 37 | - function (Item $item) { |
|
| 37 | + function(Item $item) { |
|
| 38 | 38 | $this->assertAttributeEquals('Index', 'title', $item->getLink()); |
| 39 | 39 | $item->getLink()->setTitle('Home'); |
| 40 | 40 | }); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $this->assertInstanceOf(Attributes::class, $activeAttributes); |
| 100 | 100 | |
| 101 | - $result = $builder->activeAttributes(function ($attributes) { |
|
| 101 | + $result = $builder->activeAttributes(function($attributes) { |
|
| 102 | 102 | $this->assertInstanceOf(Attributes::class, $attributes); |
| 103 | 103 | |
| 104 | 104 | return $attributes->get('class'); |
@@ -111,9 +111,9 @@ discard block |
||
| 111 | 111 | { |
| 112 | 112 | $builder = $this->builderFactory(); |
| 113 | 113 | |
| 114 | - $group = $builder->group('test', function (Item $item) use ($builder) { |
|
| 114 | + $group = $builder->group('test', function(Item $item) use ($builder) { |
|
| 115 | 115 | $this->assertAttributeEquals($builder, 'builder', $item); |
| 116 | - }, function (Builder $menu) use ($builder) { |
|
| 116 | + }, function(Builder $menu) use ($builder) { |
|
| 117 | 117 | $this->assertEquals($builder->activeAttributes()->all(), $menu->activeAttributes()->all()); |
| 118 | 118 | }); |
| 119 | 119 | |
@@ -127,18 +127,18 @@ discard block |
||
| 127 | 127 | $index = $builder->add('index', 'Index Page', '/'); |
| 128 | 128 | $index->getLink()->getAttributes()->push(['class' => 'menu-link']); |
| 129 | 129 | |
| 130 | - $builder->group('orders', function ($item) { |
|
| 130 | + $builder->group('orders', function($item) { |
|
| 131 | 131 | $item->getAttributes()->push(['class' => 'child-menu']); |
| 132 | 132 | |
| 133 | 133 | $link = $item->getLink(); |
| 134 | 134 | $link->setTitle('Orders'); |
| 135 | 135 | $link->setUrl('javascript:;'); |
| 136 | 136 | |
| 137 | - }, function ($menu) { |
|
| 137 | + }, function($menu) { |
|
| 138 | 138 | $menu->add('all', 'All', '/orders/all'); |
| 139 | 139 | $menu->add('type_1', 'Type 1', '/orders/1', [], ['class' => 'text-color-red']); |
| 140 | 140 | |
| 141 | - $menu->add('type_2', 'Type 2', '/orders/2', [], [], function ($item) { |
|
| 141 | + $menu->add('type_2', 'Type 2', '/orders/2', [], [], function($item) { |
|
| 142 | 142 | $item->getLink()->getAttributes()->push(['data-attribute' => 'value']); |
| 143 | 143 | }); |
| 144 | 144 | }); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $builder = $this->builderFactory(); |
| 155 | 155 | |
| 156 | 156 | $builder->add('index', 'Index Page', '/'); |
| 157 | - $builder->add('login', 'Login', '/login')->setDisplayRule(function () { |
|
| 157 | + $builder->add('login', 'Login', '/login')->setDisplayRule(function() { |
|
| 158 | 158 | return true; |
| 159 | 159 | }); |
| 160 | 160 | $builder->add('admin', 'Admin', '/admin')->setDisplayRule(false); |
@@ -51,8 +51,7 @@ |
||
| 51 | 51 | public function buildAttributes($attributes = []) |
| 52 | 52 | { |
| 53 | 53 | $attributes = $this->isActive() ? |
| 54 | - Attributes::mergeArrayValues($this->builder->activeAttributes()->all(), $attributes) : |
|
| 55 | - $attributes; |
|
| 54 | + Attributes::mergeArrayValues($this->builder->activeAttributes()->all(), $attributes) : $attributes; |
|
| 56 | 55 | |
| 57 | 56 | return $this->attributes->build($attributes); |
| 58 | 57 | } |
@@ -152,7 +152,7 @@ |
||
| 152 | 152 | */ |
| 153 | 153 | public function setType($type) |
| 154 | 154 | { |
| 155 | - $this->type = (string)$type; |
|
| 155 | + $this->type = (string) $type; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | |
| 48 | 48 | protected function registerSingleton() |
| 49 | 49 | { |
| 50 | - $this->app->singleton('menu', function (Container $app) { |
|
| 50 | + $this->app->singleton('menu', function(Container $app) { |
|
| 51 | 51 | return new Menu($app); |
| 52 | 52 | }); |
| 53 | 53 | $this->app->alias('menu', MenuContract::class); |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | public function make($name, $callback, $type = Builder::UL, $attributes = [], $activeAttributes = []) |
| 37 | 37 | { |
| 38 | - if(!is_callable($callback)) { |
|
| 38 | + if (!is_callable($callback)) { |
|
| 39 | 39 | throw new \InvalidArgumentException('Argument must be callable'); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -20,9 +20,9 @@ |
||
| 20 | 20 | public function canDisplay() |
| 21 | 21 | { |
| 22 | 22 | if (is_callable($this->rule)) { |
| 23 | - return (bool)call_user_func($this->rule); |
|
| 23 | + return (bool) call_user_func($this->rule); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - return (bool)$this->rule; |
|
| 26 | + return (bool) $this->rule; |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | \ No newline at end of file |
@@ -1,7 +1,12 @@ |
||
| 1 | 1 | @if ($menu) |
| 2 | 2 | <{{ $menu->getType() }}{!! $menu->buildAttributes() !!}> |
| 3 | 3 | @foreach ($menu->all() as $value) |
| 4 | - <?php $isGroup = $value instanceof \Malezha\Menu\Entity\Group; if ($isGroup) $item = $value->item(); else $item = $value; ?> |
|
| 4 | + <?php $isGroup = $value instanceof \Malezha\Menu\Entity\Group; if ($isGroup) { |
|
| 5 | + $item = $value->item(); |
|
| 6 | +} else { |
|
| 7 | + $item = $value; |
|
| 8 | +} |
|
| 9 | +?> |
|
| 5 | 10 | @if($item->canDisplay()) |
| 6 | 11 | <li{!! $item->buildAttributes() !!}> |
| 7 | 12 | <a href="{{ $item->getLink()->getUrl() }}"{!! $item->getLink()->buildAttributes() !!}>{!! $item->getLink()->getTitle() !!}</a> |