diff --git a/skolehjem/app/Helpers/Detector.php b/skolehjem/app/Helpers/Detector.php index 6b9481d..a79887b 100644 --- a/skolehjem/app/Helpers/Detector.php +++ b/skolehjem/app/Helpers/Detector.php @@ -3,9 +3,7 @@ namespace App\Helpers; - - - +use Illuminate\Support\Facades\Auth; use Jenssegers\Agent\Agent; class Detector @@ -16,7 +14,11 @@ class Detector if($agent->isMobile()) { return view(config("detector.mobilePath") . "." . $viewName, $args); + } else if(Auth()->user() !== null) { + if (Auth()->user()->can('admin.panel.show') == true) + return view(config("detector.defaultPath") . "." . $viewName, $args); } - return view(config("detector.defaultPath") . "." . $viewName, $args); + + return view(config("detector.mobilePath") . "." . $viewName, $args); } } diff --git a/skolehjem/app/Providers/DetectorServiceProvider.php b/skolehjem/app/Providers/DetectorServiceProvider.php index c34f089..49e00ac 100644 --- a/skolehjem/app/Providers/DetectorServiceProvider.php +++ b/skolehjem/app/Providers/DetectorServiceProvider.php @@ -3,6 +3,7 @@ namespace App\Providers; use Illuminate\Http\Response; +use Illuminate\Support\Facades\Auth; use Illuminate\Support\ServiceProvider; use Jenssegers\Agent\Facades\Agent; @@ -28,8 +29,12 @@ class DetectorServiceProvider extends ServiceProvider Response::macro("detect", function ($view, $args = []) { if(Agent::isMobile()) { return view(config("detector.mobilePath") . "." . $view, $args); + } else if(Auth()->user() !== null){ + if(Auth()->user()->can('admin.panel.show') == true) + return view(config("detector.defaultPath") . "." . $view, $args); } - return view(config("detector.defaultPath") . "." . $view, $args); + + return view(config("detector.mobilePath") . "." . $view, $args); }); } }