Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit 9606795

Browse files
committed
minor edits
- redir to '/' if current route ancestor is not found under current locale - clear cache when child is add to diff menu and removed from original list - rdme
1 parent 4e12374 commit 9606795

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@
3535
]
3636
```
3737

38+
- the package relay heavily on caching through **Redis**, so make sure to check the [docs](https://laravel.com/docs/5.4/redis) for installation & configuration.
39+
3840
- publish the packages assets with `php artisan vendor:publish`
3941
- for simpleMenu [Wiki](https://github.com/ctf0/simple-menu/wiki/Publish)
40-
- also check the **Dependencies** packages for "config/options/migrations".
42+
- also check the **Dependencies** packages for "configuration/options/migrations".
4143

4244
## Config
4345
**config/simpleMenu.php**

src/Controllers/Admin/Traits/MenuOps.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,13 @@ public function removeChild(Request $request)
7575
protected function saveListToDb($list)
7676
{
7777
foreach ($list as $one) {
78+
$child = $this->findPage($one->id);
7879
$parent = $this->findPage($one->parent_id);
7980

80-
$this->findPage($one->id)->makeChildOf($parent);
81-
$parent->touch();
81+
$child->makeChildOf($parent);
82+
83+
$child->cleanData();
84+
$parent->cleanData();
8285

8386
if ($one->children) {
8487
$this->saveListToDb($one->children);

src/Models/Page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,6 @@ public function cleanData()
145145
$this->clearCache('_nests');
146146

147147
// clear menu cache
148-
return $this->clearCache('Menu');
148+
$this->clearCache('Menu');
149149
}
150150
}

src/Traits/NavigationTrait.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ public function getUrl($code)
2121
{
2222
$name = Route::currentRouteName();
2323

24+
// redir to '/' if current route ancestor is not found under current locale
25+
if ($bc = $this->getRouteData($name)['breadCrumb']) {
26+
if (!$this->searchForRoute($bc->pluck('route_name')->first(), $code)) {
27+
return LaravelLocalization::getLocalizedURL($code, url('/'), [], true);
28+
}
29+
}
30+
2431
// routeName is not saved in the db (ex.php artisan make:auth)
2532
// or only url
2633
$routesListFile = include $this->listFileDir;

0 commit comments

Comments
 (0)