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
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']);
}
}