From 070ff2e3c64b2a2a26945bd55b4d12960c8db781 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 22 Jun 2020 21:08:09 +0200 Subject: [PATCH] Implemented first mobile detected route:) --- skolehjem/app/Helpers/Detector.php | 22 +++++++++++++++++++ .../app/Http/Controllers/UserController.php | 3 ++- skolehjem/config/detector.php | 7 ++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 skolehjem/app/Helpers/Detector.php create mode 100644 skolehjem/config/detector.php diff --git a/skolehjem/app/Helpers/Detector.php b/skolehjem/app/Helpers/Detector.php new file mode 100644 index 0000000..6b9481d --- /dev/null +++ b/skolehjem/app/Helpers/Detector.php @@ -0,0 +1,22 @@ +isMobile()) { + return view(config("detector.mobilePath") . "." . $viewName, $args); + } + return view(config("detector.defaultPath") . "." . $viewName, $args); + } +} diff --git a/skolehjem/app/Http/Controllers/UserController.php b/skolehjem/app/Http/Controllers/UserController.php index dc7ac64..ac603d5 100644 --- a/skolehjem/app/Http/Controllers/UserController.php +++ b/skolehjem/app/Http/Controllers/UserController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Helpers\Detector; use Illuminate\Http\Request; use App\User; use Illuminate\Support\Facades\Auth; @@ -31,7 +32,7 @@ class UserController extends Controller { $users = User::query()->paginate($request->query("page", 20)); - return view("admin.users.index", [ "users" => $users ]); + return Detector::View("users.index", [ "users" => $users ]); } /** diff --git a/skolehjem/config/detector.php b/skolehjem/config/detector.php new file mode 100644 index 0000000..e1fb44b --- /dev/null +++ b/skolehjem/config/detector.php @@ -0,0 +1,7 @@ + "admin", + + "mobilePath" => "app", +];