@@ -20,7 +20,7 @@ class SimpleMenuServiceProvider extends ServiceProvider
20
20
*/
21
21
public function boot ()
22
22
{
23
- $ this ->file = app ( 'files ' ) ;
23
+ $ this ->file = $ this -> app [ 'files ' ] ;
24
24
25
25
$ this ->packagePublish ();
26
26
$ this ->observers ();
@@ -29,7 +29,7 @@ public function boot()
29
29
$ this ->app ['simplemenu ' ];
30
30
31
31
// append extra data
32
- if (!app ( 'cache ' ) ->store ('file ' )->has ('ct-sm ' )) {
32
+ if (!$ this -> app [ 'cache ' ] ->store ('file ' )->has ('ct-sm ' )) {
33
33
$ this ->autoReg ();
34
34
}
35
35
}
@@ -76,12 +76,12 @@ protected function packagePublish()
76
76
*/
77
77
protected function observers ()
78
78
{
79
- $ config = config ('simpleMenu.models ' );
79
+ $ models = $ this -> app [ ' config ' ]-> get ('simpleMenu.models ' );
80
80
81
- if ($ config ) {
82
- app (array_get ($ config , 'page ' ))->observe (PageObserver::class);
83
- app (array_get ($ config , 'menu ' ))->observe (MenuObserver::class);
84
- app (array_get ($ config , 'user ' ))->observe (UserObserver::class);
81
+ if ($ models ) {
82
+ $ this -> app -> make (array_get ($ models , 'page ' ))->observe (PageObserver::class);
83
+ $ this -> app -> make (array_get ($ models , 'menu ' ))->observe (MenuObserver::class);
84
+ $ this -> app -> make (array_get ($ models , 'user ' ))->observe (UserObserver::class);
85
85
}
86
86
}
87
87
@@ -92,16 +92,14 @@ protected function observers()
92
92
*/
93
93
protected function macros ()
94
94
{
95
- // alias to "Route::is()" but with support for params
96
- app ('url ' )->macro ('is ' , function ($ route_name , $ params = null ) {
97
- if ($ params ) {
98
- return request ()->url () == route ($ route_name , $ params );
99
- }
100
-
101
- return request ()->url () == route ($ route_name );
95
+ // same as "Route::is()" but better
96
+ $ this ->app ['url ' ]->macro ('is ' , function ($ route_name , $ params = null ) {
97
+ return $ params
98
+ ? request ()->url () == route ($ route_name , $ params )
99
+ : request ()->url () == route ($ route_name );
102
100
});
103
101
104
- app ( 'url ' ) ->macro ('has ' , function ($ needle ) {
102
+ $ this -> app [ 'url ' ] ->macro ('has ' , function ($ needle ) {
105
103
return str_contains ($ this ->current (), $ needle );
106
104
});
107
105
}
@@ -115,7 +113,7 @@ protected function viewComp()
115
113
{
116
114
view ()->composer ('SimpleMenu::admin.* ' , function ($ view ) {
117
115
$ view ->with ([
118
- 'crud_prefix ' => config ('simpleMenu.crud_prefix ' ),
116
+ 'crud_prefix ' => $ this -> app [ ' config ' ]-> get ('simpleMenu.crud_prefix ' ),
119
117
]);
120
118
});
121
119
}
@@ -148,7 +146,7 @@ protected function autoReg()
148
146
}
149
147
150
148
// run check once
151
- app ( 'cache ' ) ->store ('file ' )->rememberForever ('ct-sm ' , function () {
149
+ $ this -> app [ 'cache ' ] ->store ('file ' )->rememberForever ('ct-sm ' , function () {
152
150
return 'added ' ;
153
151
});
154
152
}
0 commit comments