Implemented first mobile detected route:)

This commit is contained in:
Sebastian 2020-06-22 21:08:09 +02:00
parent f5fd0eb5bd
commit 070ff2e3c6
3 changed files with 31 additions and 1 deletions

View File

@ -0,0 +1,22 @@
<?php
namespace App\Helpers;
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);
}
return view(config("detector.defaultPath") . "." . $viewName, $args);
}
}

View File

@ -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 ]);
}
/**

View File

@ -0,0 +1,7 @@
<?php
return [
"defaultPath" => "admin",
"mobilePath" => "app",
];