forked from mcamara/laravel-localization
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add translatable route parameters (mcamara#676)
* Add new Interface for translating RouteParameter * Add instructions to use translatable route paramters * Add route-model-binding to translatable slugs * Correct Interface path in Readme * Fixes PSR2 for new test method * Update Readme Add example for route-model-binding
- Loading branch information
1 parent
72a2285
commit 1497c94
Showing
5 changed files
with
85 additions
and
52 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
13 changes: 13 additions & 0 deletions
13
src/Mcamara/LaravelLocalization/Interfaces/LocalizedUrlRoutable.php
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,13 @@ | ||
<?php | ||
|
||
namespace Mcamara\LaravelLocalization\Interfaces; | ||
|
||
interface LocalizedUrlRoutable | ||
{ | ||
/** | ||
* Get the value of the model's localized route key. | ||
* | ||
* @return mixed | ||
*/ | ||
public function getLocalizedRouteKey($locale); | ||
} |
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
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,16 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Mcamara\LaravelLocalization\Interfaces\LocalizedUrlRoutable; | ||
|
||
class ModelWithTranslatableRoutes extends Model implements LocalizedUrlRoutable | ||
{ | ||
public function getLocalizedRouteKey($locale) | ||
{ | ||
if($locale == 'es'){ | ||
return 'empresa'; | ||
} | ||
|
||
return 'company'; | ||
} | ||
} |