2
2
3
3
namespace ctf0 \SimpleMenu \Traits ;
4
4
5
+ use Illuminate \Support \Arr ;
5
6
use Mcamara \LaravelLocalization \Facades \LaravelLocalization ;
6
7
7
8
trait Navigation
@@ -22,14 +23,16 @@ public function getUrl($code)
22
23
23
24
// redir to '/' if the first item in "bc" is in diff locale
24
25
$ bc = $ this ->getRouteData ($ name )['breadCrumb ' ];
26
+
25
27
if (isset ($ bc ) && count ($ bc ) && !$ this ->searchForRoute ($ bc ->pluck ('route_name ' )->first (), $ code )) {
26
28
return LaravelLocalization::getLocalizedURL ($ code , url ('/ ' ), [], true );
27
29
}
28
30
29
31
// routeName is not saved in the db (ex.php artisan make:auth)
30
32
// or only url
31
33
$ routesListFile = include $ this ->listFileDir ;
32
- if (is_null ($ name ) || !array_get ($ routesListFile , $ name )) {
34
+
35
+ if (is_null ($ name ) || !isset ($ routesListFile [$ name ])) {
33
36
return LaravelLocalization::getLocalizedURL ($ code , null , [], true );
34
37
}
35
38
@@ -54,7 +57,7 @@ public function getUrl($code)
54
57
*
55
58
* @return [type] [description]
56
59
*/
57
- public function getRoute ($ crntRouteName , array $ params = null )
60
+ public function getRoute ($ crntRouteName , $ params = null )
58
61
{
59
62
// where route is available under one locale but not the other
60
63
if (!app ('router ' )->has ($ crntRouteName )) {
@@ -71,7 +74,7 @@ public function getRoute($crntRouteName, array $params = null)
71
74
if ($ crntRouteName == $ key ) {
72
75
session ([$ key => $ value ]);
73
76
74
- // fix link not being 'is-active' when "hideDefaultLocaleInURL => true"
77
+ // fix link not being 'is-active'when"hideDefaultLocaleInURL => true"
75
78
$ finalUrl = LaravelLocalization::getLocalizedURL ($ locale , url ($ this ->getParams ($ url , $ value )), [], $ forceDefaultLocation );
76
79
$ this ->urlRoute = $ finalUrl ;
77
80
@@ -146,7 +149,7 @@ protected function searchForRoute($name, $code)
146
149
$ routesListFile = include $ this ->listFileDir ;
147
150
148
151
// check if we have a link according to that "routeName & code"
149
- return array_get ($ routesListFile , "$ name. $ code " , false );
152
+ return Arr:: get ($ routesListFile , "$ name. $ code " , false );
150
153
}
151
154
152
155
/**
@@ -170,9 +173,9 @@ public function render($pages, $classes = null, $params = null)
170
173
$ a = config ('simpleMenu.listClasses.a ' );
171
174
break ;
172
175
default :
173
- $ ul = array_get ( $ classes, 'ul ' ) ;
174
- $ li = array_get ( $ classes, 'li ' ) ;
175
- $ a = array_get ( $ classes, 'a ' ) ;
176
+ $ ul = $ classes[ 'ul ' ] ;
177
+ $ li = $ classes[ 'li ' ] ;
178
+ $ a = $ classes[ 'a ' ] ;
176
179
break ;
177
180
}
178
181
@@ -194,7 +197,7 @@ public function render($pages, $classes = null, $params = null)
194
197
protected function getHtml ($ pages , $ ul_ClassName , $ li_ClassName , $ a_ClassName , $ params , $ url )
195
198
{
196
199
$ html = '' ;
197
- $ html .= "<ul class= \"{$ ul_ClassName }\"> " ;
200
+ $ html .= "<ul class = \"{$ ul_ClassName }\"> " ;
198
201
199
202
foreach ($ pages as $ page ) {
200
203
// escape empty url
@@ -205,8 +208,8 @@ protected function getHtml($pages, $ul_ClassName, $li_ClassName, $a_ClassName, $
205
208
$ routeUrl = $ this ->getRoute ($ page ->route_name , $ params );
206
209
$ isActive = ($ url == $ routeUrl ? $ a_ClassName : '' );
207
210
208
- $ html .= "<li class= \"{$ li_ClassName }\"> " ;
209
- $ html .= "<a href= \"{$ routeUrl }\" class= \"{$ isActive }\"> {$ page ->title }</a> " ;
211
+ $ html .= "<li class = \"{$ li_ClassName }\"> " ;
212
+ $ html .= "<a href = \"{$ routeUrl }\" class = \"{$ isActive }\"> {$ page ->title }</a> " ;
210
213
211
214
if ($ childs = $ page ->nests ) {
212
215
$ html .= $ this ->getHtml ($ childs , $ ul_ClassName , $ li_ClassName , $ a_ClassName , $ params , $ url );
0 commit comments