m2collective/laravel-defining-user-device
Composer 安装命令:
composer require m2collective/laravel-defining-user-device
包简介
A package for detecting the user's device.
README 文档
README
A package for detecting the user's device.
Installation
You can install the package via composer:
composer require m2collective/laravel-defining-user-device
The package will automatically register itself.
Usage
By installing the package, determine the user's device type.
Dependency injection
An example of using a package with the dependency injection:
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 { //... } } } } }
Facades
An example of using a package with the facades:
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 { //... } } } } }
Blade Directives
An example of using a package with the blade directive:
@isDesktop
//...
@elseIsDesktop
//...
@endIsDesktop
or
@isMobile
//...
@elseIsMobile
//...
@endIsMobile
or
@isTablet
//...
@elseIsTablet
//...
@endIsTablet
License
The MIT License (MIT). Please see the License file for more information.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-17