Skip to content

Commit 66e7cf1

Browse files
Merge pull request #1 from hexadog/develop
Develop
2 parents 0e8547d + a1811e5 commit 66e7cf1

File tree

12 files changed

+301
-14
lines changed

12 files changed

+301
-14
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ php artisan vendor:publish --provider="Hexadog\MenusManager\Providers\PackageSer
304304

305305
<!-- omit in toc -->
306306
## Credits
307+
- This package is inspired by the work of [rinvex/laravel-menus](https://github.com/rinvex/laravel-menus)
307308
- Logo made by [DesignEvo free logo creator](https://www.designevo.com/logo-maker/)
308309

309310
<!-- omit in toc -->

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
"Hexadog\\MenusManager\\": "src"
2929
}
3030
},
31+
"autoload-dev": {
32+
"psr-4": {
33+
"Hexadog\\MenusManager\\Tests\\": "tests"
34+
}
35+
},
3136
"extra": {
3237
"laravel": {
3338
"providers": [

resources/views/components/children.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div x-show="open" {{ $attributes }}>
22
@foreach($items as $item)
33
@if ($item->isDivider())
4-
<x-menus-divider class="py-2 px-16 border-0 bg-gray-500 text-gray-500 h-px" />
4+
<x-menus-divider :item="$item" class="py-2 px-16 border-0 bg-gray-500 text-gray-500 h-px" />
55
@else
66
@if($item->isActive())
77
<x-menus-item :item="$item" class="py-2 px-16 block text-sm text-gray-600 hover:bg-blue-500 hover:text-white bg-gray-200 text-gray-700 border-r-4 border-gray-700" />

resources/views/components/menu.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<nav {{ $attributes }}>
22
@foreach($items as $item)
33
@if($item->isDivider())
4-
<x-menus-divider class="border-0 bg-gray-500 text-gray-500 h-px" />
4+
<x-menus-divider :item="$item" class="border-0 bg-gray-500 text-gray-500 h-px" />
55
@else
66
@if($item->isActive())
77
<x-menus-item :item="$item" class="w-full flex justify-between items-center py-3 px-6 text-gray-600 cursor-pointer hover:bg-gray-100 hover:text-gray-700 focus:outline-none bg-gray-200 text-gray-700 border-r-4 border-gray-700" />

src/Components/Divider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(Item $item)
3333
*/
3434
public function render()
3535
{
36-
if ($this->item->isVisible()) {
36+
if ($this->item && $this->item->isVisible()) {
3737
return view('menus-manager::components.divider');
3838
}
3939

src/Components/Header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(Item $item)
3333
*/
3434
public function render()
3535
{
36-
if ($this->item->isVisible()) {
36+
if ($this->item && $this->item->isVisible()) {
3737
return view('menus-manager::components.header');
3838
}
3939

src/Components/Icon.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ class Icon extends Component
1212
*
1313
* @var string
1414
*/
15-
protected $icon;
15+
public $icon;
1616

1717
/**
1818
* The item
1919
*
2020
* @var Item
2121
*/
22-
protected $item;
22+
public $item;
2323

2424
/**
2525
* Create the component instance
@@ -28,10 +28,10 @@ class Icon extends Component
2828
*
2929
* @return void
3030
*/
31-
public function __construct(Item $item = null)
31+
public function __construct(Item $item)
3232
{
3333
$this->item = $item;
34-
$this->icon = $item->hasIcon() ? $item->icon : null;
34+
$this->icon = $item && $item->hasIcon() ? $item->icon : null;
3535
}
3636

3737
/**
@@ -41,7 +41,7 @@ public function __construct(Item $item = null)
4141
*/
4242
public function render()
4343
{
44-
if ($this->icon) {
44+
if ($this->item && $this->icon) {
4545
return view('menus-manager::components.icon');
4646
}
4747

src/Components/Item.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(MenusManagerItem $item)
3232
*/
3333
public function render()
3434
{
35-
if ($this->item->isVisible()) {
35+
if ($this->item && $this->item->isVisible()) {
3636
if ($this->item->isHeader()) {
3737
return view('menus-manager::components.header');
3838
}

src/Components/Menu.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public function __construct($name)
4242
*/
4343
public function render()
4444
{
45-
return view('menus-manager::components.menu');
45+
if ($this->menu) {
46+
return view('menus-manager::components.menu');
47+
}
48+
49+
return '';
4650
}
4751
}

src/Item.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ public function __construct(array $properties = [], $parent = null)
7474
*/
7575
public function __get($key)
7676
{
77+
if ($key === 'properties') {
78+
return $this->properties;
79+
}
80+
7781
return Arr::get($this->properties, $key);
7882
}
7983

@@ -142,13 +146,13 @@ public function fill($properties): Item
142146
/**
143147
* Get the item attributes as HTML String
144148
*
145-
* @param array $attributes
149+
* @param mixed $except
146150
*
147151
* @return string
148152
*/
149-
public function getAttributes(array $attributes = [])
153+
public function getAttributes($except = null)
150154
{
151-
return $this->htmlAttributes(array_merge($this->attributes, $attributes));
155+
return $this->htmlAttributes(Arr::except($this->attributes, $except));
152156
}
153157

154158
/**

0 commit comments

Comments
 (0)