Got the mobile route to work
This commit is contained in:
parent
070ff2e3c6
commit
4ddc765082
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Helpers\Detector;
|
use App\Helpers\Detector;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
use App\User;
|
use App\User;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
@ -32,7 +33,7 @@ class UserController extends Controller
|
||||||
{
|
{
|
||||||
$users = User::query()->paginate($request->query("page", 20));
|
$users = User::query()->paginate($request->query("page", 20));
|
||||||
|
|
||||||
return Detector::View("users.index", [ "users" => $users ]);
|
return Response::detect("users.index", [ "users" => $users ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Jenssegers\Agent\Facades\Agent;
|
||||||
|
|
||||||
|
class DetectorServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
Response::macro("detect", function ($view, $args) {
|
||||||
|
if(Agent::isMobile()) {
|
||||||
|
return view(config("detector.mobilePath") . "." . $view, $args);
|
||||||
|
}
|
||||||
|
return view(config("detector.defaultPath") . "." . $view, $args);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -177,6 +177,10 @@ return [
|
||||||
App\Providers\EventServiceProvider::class,
|
App\Providers\EventServiceProvider::class,
|
||||||
App\Providers\RouteServiceProvider::class,
|
App\Providers\RouteServiceProvider::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Custom Service Prviders
|
||||||
|
*/
|
||||||
|
App\Providers\DetectorServiceProvider::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue