Example #1
0
 /**
  * Controller method for Route creation
  * In routes.php / web.php use:
  * Route::get('{any}', '\App\Page@route')->where('any', '(.*)');
  */
 public function route($any, Request $request)
 {
     # Start walking the page tree
     $navigationHtml = $this->walk(null, 0, Request::segments());
     # If currentPage isn't set raise a custom 404
     if (!$this->currentPage) {
         abort(404);
     }
     # Return the page view
     if ($this->currentPage['parent'] > 0) {
         $this->currentPage['view'] = 'detail';
     }
     return view($this->currentPage['view'] ? $this->currentPage['view'] : 'page', ['page' => $this->currentPage, 'navigationHtml' => $navigationHtml]);
 }