what's up? I'm the last two days trying to use a library of DeviceIndentify, Agent. This is a library based on Mobile Detect, but for LARAVEL.
I already read the README.md and searched about how to use the library correctly, but I don't get it.
I already installed the library as I should, but I'm not sure about how to use it.
At my tests, I found some problems. I created a Controller where I added the following line codes:
use Jenssegers\Agent\Facades\Agent;
class AgentController extends Controller
{
public function DeviceCheck(){
$device = "desktop/";
$agent = new Agent();
if($agent->isMobile() == true){
$device = "mobile/";
}
return $device;
}
}
And I expected to use the $device
var in the path of the view()
method on my RouteController.php
.Something like:
// At Controller
...
return view($device . "welcome");
This because I divided my views between views/desktop/
and views/mobile/
.
It's only worked in mobile devices, you should test/open page on a mobile device to get that
$device
data.I recommended you to head over to https://github.com/jenssegers/agent#laravel-optional to proper setup.