Ekapp/skolehjem/app/Providers/DetectorServiceProvider.php

36 lines
717 B
PHP
Raw Normal View History

2020-06-23 04:42:43 +00:00
<?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()
{
2020-06-24 06:21:00 +00:00
Response::macro("detect", function ($view, $args = []) {
2020-06-23 04:42:43 +00:00
if(Agent::isMobile()) {
return view(config("detector.mobilePath") . "." . $view, $args);
}
return view(config("detector.defaultPath") . "." . $view, $args);
});
}
}