43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Http\Response;
|
|
use Illuminate\Support\Facades\Auth;
|
|
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);
|
|
} else if(Auth()->user() !== null){
|
|
if(Auth()->user()->can('admin.panel.show') == true)
|
|
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);
|
|
});
|
|
}
|
|
}
|