-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from tormjens/master
Enable changing the route group prefix
- Loading branch information
Showing
3 changed files
with
40 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
return [ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Route Configuration | ||
|-------------------------------------------------------------------------- | ||
*/ | ||
'route' => [ | ||
'prefix' => 'countries', // change this to whatever you'd like | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
/** | ||
* Class ServiceProvider | ||
* | ||
* @package Galahad\LaravelAddressing | ||
* @author Chris Morrell | ||
* @author Junior Grossi <[email protected]> | ||
*/ | ||
|
@@ -24,6 +23,9 @@ public function boot() | |
{ | ||
$this->bootRoutes(); | ||
$this->loadTranslationsFrom(__DIR__.'/../lang', 'laravel-addressing'); | ||
$this->publishes([ | ||
__DIR__.'/../config/addressing.php' => config_path('addressing.php'), | ||
]); | ||
} | ||
|
||
/** | ||
|
@@ -51,7 +53,8 @@ protected function bootRoutes() | |
|
||
try { | ||
$route = $this->app->make('router'); | ||
$route->group(['prefix' => 'galahad/addressing'], function ($route) { | ||
$prefix = config('addressing.route.prefix', 'galahad/addressing'); | ||
$route->group(['prefix' => $prefix], function ($route) use ($prefix) { | ||
$route->get('/{country}/administrative-areas', [ | ||
'as' => 'galahad.addressing.administrative-areas', | ||
'uses' => '\\Galahad\\LaravelAddressing\\Controller@getAdministrativeAreas', | ||
|
@@ -81,10 +84,14 @@ protected function registerValidators() | |
$validator->extend('country_name', CountryValidator::class.'@validateCountryName'); | ||
|
||
// Administrative Area validators | ||
$validator->extend('administrative_area_code', | ||
AdministrativeAreaValidator::class.'@validateAdministrativeAreaCode'); | ||
$validator->extend('administrative_area_name', | ||
AdministrativeAreaValidator::class.'@validateAdministrativeAreaName'); | ||
$validator->extend( | ||
'administrative_area_code', | ||
AdministrativeAreaValidator::class.'@validateAdministrativeAreaCode' | ||
); | ||
$validator->extend( | ||
'administrative_area_name', | ||
AdministrativeAreaValidator::class.'@validateAdministrativeAreaName' | ||
); | ||
$validator->extend('administrative_area', AdministrativeAreaValidator::class.'@validateAdministrativeArea'); | ||
|
||
// Postal Code validator | ||
|