PHP code example of m2collective / laravel-defining-user-device
1. Go to this page and download the library: Download m2collective/laravel-defining-user-device library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
m2collective / laravel-defining-user-device example snippets
use M2Collective\DefiningUserDevice\DefiningUserDevice;
final class Example
{
/**
* @var DefiningUserDevice
*/
protected DefiningUserDevice $definingUserDevice;
/**
* @param DefiningUserDevice $definingUserDevice
*/
public function __construct(
DefiningUserDevice $definingUserDevice
) {
$this->definingUserDevice = $definingUserDevice;
}
/**
* @return mixed
*/
public function isDevice(): mixed {
if($this->definingUserDevice->isDesktop()) {
//...
} else {
if($this->definingUserDevice->isMobile()) {
//...
} else {
if($this->definingUserDevice->isTablet()) {
//...
} else {
//...
}
}
}
}
}
use M2Collective\DefiningUserDevice\Facades\DefiningUserDevice;
final class Example
{
/**
* @return mixed
*/
public function isDevice(): mixed {
if(DefiningUserDevice::isDesktop()) {
//...
} else {
if(DefiningUserDevice::isMobile()) {
//...
} else {
if(DefiningUserDevice::isTablet()) {
//...
} else {
//...
}
}
}
}
}
shell
php artisan m2collective:defining-user-device:publish-config