Implemented first mobile detected route:)
This commit is contained in:
parent
f5fd0eb5bd
commit
070ff2e3c6
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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 ]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
"defaultPath" => "admin",
|
||||
|
||||
"mobilePath" => "app",
|
||||
];
|
Loading…
Reference in New Issue