Skip to content

Commit

Permalink
fix : non found route name
Browse files Browse the repository at this point in the history
  • Loading branch information
MoamenEltouny committed Mar 16, 2022
1 parent 4d0d1c4 commit a3acfb3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Classes/Localization.php
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Route;
use Symfony\Component\Routing\Exception\RouteNotFoundException;

/**
* Laravel URL Localization Manager
Expand Down Expand Up @@ -396,6 +397,9 @@ public function route(string $key, $params = [])
// Depends on Type
if ($this->type == 'sub-directory') {
$route = Route::getRoutes()->getByName($key);

if(!$route)
throw new RouteNotFoundException('[' . $key . '] Route has not found.');

if (substr($route->getPrefix(), 0, 9) != '{locale?}')
$route->prefix('/{locale?}');
Expand Down

0 comments on commit a3acfb3

Please sign in to comment.