Merge branch 'master' of https://github.com/sebathefox/skolehjem-webapp into master
This commit is contained in:
@@ -3,9 +3,7 @@
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
|
||||
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Jenssegers\Agent\Agent;
|
||||
|
||||
class Detector
|
||||
@@ -16,7 +14,13 @@ 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);
|
||||
if($viewName == "users.login" || $viewName == "users.logout")
|
||||
return view(config("detector.mobilePath") . "." . $viewName, $args);
|
||||
|
||||
return view("errors.403", $args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,16 @@ class RootController extends Controller
|
||||
|
||||
if(auth()->user()->can('admin.panel.show')) {
|
||||
if(Response::detect("root.index")->name() == "admin.root.index")
|
||||
return Response::detect("root.index");
|
||||
return view("admin.root.index");
|
||||
else {
|
||||
$news = News::query()->orderBy('id', 'desc')->paginate($perPage);
|
||||
return Response::detect("root.index", ["news" => $news]);
|
||||
return view("app.root.index", ["news" => $news]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$news = News::query()->orderBy('id', 'desc')->paginate($perPage, ['*'], "page");
|
||||
|
||||
return view('app.root.index', ["news" => $news]);
|
||||
return Response::detect('root.index', ["news" => $news]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,14 @@ 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);
|
||||
if($view == "users.login" || $view == "users.logout")
|
||||
return view(config("detector.mobilePath") . "." . $view, $args);
|
||||
|
||||
return view("errors.403", $args);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user