承接 m2collective/laravel-defining-user-device 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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.

Laravel PHP

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.

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-17