Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Update docs and Requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
TiBianMod committed Nov 17, 2016
1 parent 668e389 commit a4c8e1e
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 46 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.idea/
*.txt
/.idea
/vendor
*.lock
*.DS_Store
.Spotlight-V100
.Trashes
.Trashes
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
}
],
"require": {
"sinergi/browser-detector": "^6.0"
"php": ">=5.5.9",
"sinergi/browser-detector": "^6.1"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion config/browser.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Sinergi\BrowserDetector\Browser;
use Sinergi\BrowserDetector\Os;
use Sinergi\BrowserDetector\Browser;

return [

Expand Down
19 changes: 9 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,27 @@ Require this package with composer using the following command
```
composer require tibian/browser-requirement
```

After updating composer, add the service provider to the providers array in config/app.php
```
```php
TiBian\BrowserRequirement\BrowserRequirementServiceProvider::class,
```

### Config
Publish the config file to change it as you wish.
```
php artisan vendor:publish
or
php artisan vendor:publish --provider="TiBian\BrowserRequirement\BrowserRequirementServiceProvider" --tag=config
```

### Usage
Open the config/browser.php and you are ready to start.

>Let set-up minimum Browser Requirement for OS X and Windows...
```
```php
Os::OSX => [
Browser::CHROME => 25,
Browser::FIREFOX => 25,
Expand All @@ -41,22 +46,16 @@ Os::WINDOWS => [
### Routes
This is a Example from the Routes you need, you are free to customize the Routes like you wish.

```
```php
Route::get("requirement-browser", "ErrorsController@browser")
->name('requirement::browser');
```

```
```php
Route::get("/", "PagesController@index")
->name('home');
```

### I'm looking for:
- Individuals who can contribute to the Documentation.
- Participation in other Open Source Projects.

> Visit my Web Site and learn more [about me](https://tibian.me)
##### Any idea for new projects, feel free to Contact me.

##### Thank you for visiting my Repository.
58 changes: 30 additions & 28 deletions src/BrowserRequirement.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,20 @@ class BrowserRequirement
protected $isUnsupportedBrowser;

/**
* OS Object
*
* @var object Os
* @var \Sinergi\BrowserDetector\Os
*/
protected $os;

/**
* Browser Object
*
* @var object Browser
* @var \Sinergi\BrowserDetector\Browser
*/
protected $browser;

/**
* BrowserRequirement constructor.
*
* @param Browser $browser
* @param Os $os
* @param \Sinergi\BrowserDetector\Browser $browser
* @param \Sinergi\BrowserDetector\Os $os
*/
public function __construct(Browser $browser, Os $os)
{
Expand All @@ -83,14 +79,34 @@ public function __construct(Browser $browser, Os $os)
}

/**
* Determine if the Browser is Unsupported
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function handle(Request $request, Closure $next)
{
if ($this->isUnsupportedBrowser) {
if (! $this->isUnsupportedPage()) {
return redirect($this->routeUnsupportedBrowser);
}
} else {
if ($this->isUnsupportedPage()) {
return redirect($this->routeSupportedBrowser);
}
}

return $next($request);
}

/**
* @return bool
*/
private function isUnsupportedBrowser()
protected function isUnsupportedBrowser()
{
if (array_key_exists($this->os->getName(), $this->supportedVersions)) {

$browsers = $this->supportedVersions[$this->os->getName()];

foreach ($browsers as $browser => $version) {
Expand All @@ -106,24 +122,10 @@ private function isUnsupportedBrowser()
}

/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
* @return bool
*/
public function handle(Request $request, Closure $next)
protected function isUnsupportedPage()
{
if ($this->isUnsupportedBrowser) {
if ($this->currentPage != $this->routeUnsupportedBrowser) {
return redirect($this->routeUnsupportedBrowser);
}
} else {
if ($this->currentPage == $this->routeUnsupportedBrowser) {
return redirect($this->routeSupportedBrowser);
}
}

return $next($request);
return $this->currentPage == $this->routeUnsupportedBrowser;
}
}
4 changes: 1 addition & 3 deletions src/BrowserRequirementServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BrowserRequirementServiceProvider extends ServiceProvider
/**
* Bootstrap the application services.
*
* @return void
* @param \Illuminate\Routing\Router $router
*/
public function boot(Router $router)
{
Expand All @@ -28,8 +28,6 @@ public function boot(Router $router)

/**
* Register the application services.
*
* @return void
*/
public function register()
{
Expand Down

0 comments on commit a4c8e1e

Please sign in to comment.