m2collective/laravel-defining-user-device

A package for detecting the user's device.

Maintainers

Package info

github.com/m2collective/laravel-defining-user-device

pkg:composer/m2collective/laravel-defining-user-device

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.0 2026-06-17 17:57 UTC

This package is not auto-updated.

Last update: 2026-06-17 21:31:30 UTC


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.