Skip to content

Commit

Permalink
[4.x] Create tree for navigation if one doesn't exist (#9032)
Browse files Browse the repository at this point in the history
Create tree for navigation if one doesn't exist
  • Loading branch information
duncanmcclean authored Dec 14, 2023
1 parent 69209cb commit 34cb4d2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Http/Controllers/CP/Navigation/NavigationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ public function show(Request $request, $nav)
$site = $request->site ?? Site::selected()->handle();

if (! $nav->existsIn($site)) {
return redirect($nav->trees()->first()->showUrl());
if ($nav->trees()->isNotEmpty()) {
return redirect($nav->trees()->first()->showUrl());
}

$nav->makeTree($site)->save();
}

$this->authorize('view', $nav->in($site), __('You are not authorized to view navs.'));
Expand Down

0 comments on commit 34cb4d2

Please sign in to comment.