|
1
|
|
|
<?php namespace Arcanesoft\Foundation\ViewComposers; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanesoft\Core\Helpers\Sidebar\Contracts\Sidebar; |
|
4
|
|
|
use Illuminate\View\View; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Class SidebarComposer |
|
8
|
|
|
* |
|
9
|
|
|
* @package Arcanesoft\Foundation\ViewComposers |
|
10
|
|
|
* @author ARCANEDEV <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
class SidebarComposer |
|
13
|
|
|
{ |
|
14
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
15
|
|
|
| Properties |
|
16
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
17
|
|
|
*/ |
|
18
|
|
|
/** |
|
19
|
|
|
* The Sidebar Helper instance. |
|
20
|
|
|
* |
|
21
|
|
|
* @var \Arcanesoft\Core\Helpers\Sidebar\Contracts\Sidebar |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $sidebar; |
|
24
|
|
|
|
|
25
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
26
|
|
|
| Constructor |
|
27
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
28
|
|
|
*/ |
|
29
|
|
|
/** |
|
30
|
|
|
* SidebarComposer constructor. |
|
31
|
|
|
* |
|
32
|
|
|
* @param \Arcanesoft\Core\Helpers\Sidebar\Contracts\Sidebar $sidebar |
|
33
|
|
|
*/ |
|
34
|
|
|
public function __construct(Sidebar $sidebar) |
|
35
|
|
|
{ |
|
36
|
|
|
$this->sidebar = $sidebar; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
40
|
|
|
| Main Functions |
|
41
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
42
|
|
|
*/ |
|
43
|
|
|
/** |
|
44
|
|
|
* Bind data to the view. |
|
45
|
|
|
* |
|
46
|
|
|
* @param \Illuminate\View\View $view |
|
47
|
|
|
*/ |
|
48
|
|
|
public function compose(View $view) |
|
49
|
|
|
{ |
|
50
|
|
|
foreach ($this->getSidebarItems() as $sidebarKey) { |
|
51
|
|
|
if (config()->has($sidebarKey)) { |
|
52
|
|
|
$this->sidebar->add(config($sidebarKey)); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
$this->sidebar->setCurrent( |
|
57
|
|
|
array_get($view->getData(), 'current_page', '') |
|
58
|
|
|
); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
62
|
|
|
| Other Functions |
|
63
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
64
|
|
|
*/ |
|
65
|
|
|
/** |
|
66
|
|
|
* Get sidebar items. |
|
67
|
|
|
* |
|
68
|
|
|
* @return array |
|
69
|
|
|
*/ |
|
70
|
|
|
private function getSidebarItems() |
|
71
|
|
|
{ |
|
72
|
|
|
return config('arcanesoft.foundation.sidebar.items', []); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|