Ekapp/skolehjem/app/Helpers/Detector.php

27 lines
721 B
PHP
Raw Permalink Normal View History

<?php
namespace App\Helpers;
2020-08-27 08:59:19 +00:00
use Illuminate\Support\Facades\Auth;
use Jenssegers\Agent\Agent;
class Detector
{
public static function View($viewName, $args) {
$agent = new Agent();
if($agent->isMobile()) {
return view(config("detector.mobilePath") . "." . $viewName, $args);
2020-08-27 08:59:19 +00:00
} else if(Auth()->user() !== null) {
if (Auth()->user()->can('admin.panel.show') == true)
return view(config("detector.defaultPath") . "." . $viewName, $args);
}
2020-08-27 10:46:07 +00:00
if($viewName == "users.login" || $viewName == "users.logout")
return view(config("detector.mobilePath") . "." . $viewName, $args);
2020-08-27 08:59:19 +00:00
2020-08-27 09:12:43 +00:00
return view("errors.403", $args);
}
}