Package Data | |
---|---|
Maintainer Username: | torkashvand |
Maintainer Contact: | m.torkashvand2009@gmail.com (Mohammad Torkashvand) |
Package Create Date: | 2016-12-23 |
Package Last Update: | 2018-08-25 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-28 15:02:04 |
Package Statistics | |
---|---|
Total Downloads: | 11 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
This middleware package adds attributes to your request object that describe the users browser. This will let you fine tune the templates or code to use based on the traits of the browser.
This project has forked from django-minidetector, and modified for PHP.
The following is added to the request:
$request->isSimpleDevice
true
for all non-desktop devices (browsers) without "modern" CSS and JS support. This includes non "smart" phones and simpler browsers like those found on game consoles and the kindle.
$request->isTouchDevice
true
for devices that use touch events.
$request->isWideDevice
true
for devices that are wider than a common mobile phone. This covers tablets and desktop browsers.
$request->isSimpleDevice
$request->isTouchDevice
$request->isWideDevice
$request->mobile
$request->isWebkit
$request->isIOSDevice
$request->isAndroidDevice
$request->isWebOSDevice
$request->isWindowsPhoneDevice
true
if the device is part of the given platform.
These give more granular information about modern smart devices. This is helpful if you want to target features to a specific device type.
$request->isWebkit
true
if the browser is webkit (desktop or mobile.)
If you only have certain route that need the distinction all you need to do is adding the middleware to it:
Route::get('/need-destination', [
'middleware'=> 'mini-detector:viewNeedDestination',
'uses' => 'NeedDestinationController@index',
]);
Of course this middleware can also be applied to a bunch of routes:
Route::group(['prefix' => 'admin', 'middleware' => 'mini-detector:viewAdmin'], function() {
//all the controllers of your admin section
...
});
You can install the package via composer:
$ composer require torkashvand/laravel-minidevicedetector
Next, you must install the service provider:
// config/app.php
'providers' => [
...
Torkashvand\MiniDeviceDetector\MiniDeviceDetectorServiceProvider::class,
];
Next, the \Torkashvand\MiniDeviceDetector\Middleware\MiniDeviceDetector::class
-middleware must be registered in the kernel:
//app/Http/Kernel.php
protected $routeMiddleware = [
...
'mini-detector' => \Torkashvand\MiniDeviceDetector\Middleware\MiniDeviceDetector::class,
];
Naming the middleware mini-detector
is just a suggestion. You can give it any name you'd like.
Route::get('/need-destination', ['middleware'=> 'mini-detector','uses' => 'NeedToDetectController@show']);
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.