]> _ Git - cubist_cms-back.git/commitdiff
#2757
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 12 Jul 2019 18:32:09 +0000 (20:32 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 12 Jul 2019 18:32:09 +0000 (20:32 +0200)
src/app/Http/Controllers/CubistPageController.php

index 6d48186dc9f849fbfb503781d8fe1d396bbe28cb..9626756a6abd60b3bebb4534535b5e44e6b67030 100644 (file)
@@ -4,6 +4,7 @@ namespace Cubist\Backpack\app\Http\Controllers;
 
 use Cubist\Backpack\app\Magic\Menu\Menu;
 use Cubist\Backpack\app\Magic\Models\CMSPage;
+use Illuminate\Http\Request;
 use Illuminate\Support\Str;
 
 class CubistPageController extends CubistFrontController
@@ -29,21 +30,31 @@ class CubistPageController extends CubistFrontController
         return view('pages.' . $page->getAttributeValue('template'), $this->data);
     }
 
-    public function catchall($main = '', $subs = '')
+    public function catchall(Request $request, $main = '', $subs = '')
     {
-
-        $path = trim($main . '/' . $subs, '/');
-        if (!$path) {
-            $path = 'home';
-        }
-        $nav = Menu::getNavigation();
-        $item = $nav->findItemWithURL($path);
-        if (null === $item) {
-            $this->_404();
+        if ($main == 'ajax') {
+            $e = explode('/', trim($subs, '/'));
+            $c = ['controller' => 'AjaxController'];
+            $c['action'] = array_shift($e);
+            $c['params'] = ['request' => $request];
+            if (count($e)) {
+                $c['params']['path'] = implode('/', $e);
+            }
+        } else {
+
+            $path = trim($main . '/' . $subs, '/');
+            if (!$path) {
+                $path = 'home';
+            }
+            $nav = Menu::getNavigation();
+            $item = $nav->findItemWithURL($path);
+            if (null === $item) {
+                $this->_404();
+            }
+
+            $c = $item->getController();
         }
 
-        $c = $item->getController();
-
         return call_user_func_array([app('App\\Http\\Controllers\\' . $c['controller']), $c['action']], $c['params']);
     }
 }