Skip to content

Commit

Permalink
Merge pull request #150 from jochensengier/master
Browse files Browse the repository at this point in the history
ignored-routes
  • Loading branch information
arcanedev-maroc committed Mar 5, 2020
2 parents 373aa76 + 2fec871 commit 28331ec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
8 changes: 8 additions & 0 deletions config/localization.php
Expand Up @@ -41,6 +41,14 @@
//
],

/* -----------------------------------------------------------------
| Ignored routes from localization
| -----------------------------------------------------------------
*/
'ignored-routes' => [
//
],

/* -----------------------------------------------------------------
| Locales
| -----------------------------------------------------------------
Expand Down
17 changes: 15 additions & 2 deletions src/Middleware/Middleware.php
Expand Up @@ -35,6 +35,13 @@ abstract class Middleware
*/
protected $except = [];

/**
* The routes that should not be localized.
*
* @var array
*/
protected $except_routes = [];

/* -----------------------------------------------------------------
| Constructor
| -----------------------------------------------------------------
Expand All @@ -47,8 +54,9 @@ abstract class Middleware
*/
public function __construct(Localization $localization)
{
$this->localization = $localization;
$this->except = config('localization.ignored-uri', []);
$this->localization = $localization;
$this->except = config('localization.ignored-uri', []);
$this->except_routes = config('localization.ignored-routes', []);
}

/* -----------------------------------------------------------------
Expand Down Expand Up @@ -129,6 +137,11 @@ protected function shouldIgnore(Request $request)
return true;
}

foreach ($this->except_routes as $except) {
if ($request->routeIs($except))
return true;
}

return false;
}

Expand Down

0 comments on commit 28331ec

Please sign in to comment.