https://github.com/dartmoon-io/laravel-route-helpers
  
  
     
    https://github.com/dartmoon-io/laravel-route-helpers
  
laravel laravel-package
        Last synced: 5 months ago 
        JSON representation
    
- Host: GitHub
 - URL: https://github.com/dartmoon-io/laravel-route-helpers
 - Owner: dartmoon-io
 - License: mit
 - Created: 2023-05-16T15:03:00.000Z (over 2 years ago)
 - Default Branch: main
 - Last Pushed: 2023-08-18T09:57:13.000Z (about 2 years ago)
 - Last Synced: 2025-05-31T16:11:42.650Z (5 months ago)
 - Topics: laravel, laravel-package
 - Language: PHP
 - Homepage:
 - Size: 36.1 KB
 - Stars: 0
 - Watchers: 1
 - Forks: 0
 - Open Issues: 0
 - 
            Metadata Files:
            
- Readme: README.md
 - License: LICENSE
 
 
Awesome Lists containing this project
README
          # Laravel Route Helpers
Add a simple Route::when macro to conditionally register routes.
## Installation
```bash
composer require dartmoon/laravel-route-helpers
```
## Usage
When the condition is true the route will be registered, otherwise it will be ignored.
```php
Route::when($condition, function () {
    Route::get('/registered/only/when/condition/is/true', fn () => 'Hello World');
});
```
For example you can register routes base on app locale.
```php
Route::when(app()->getLocale() == 'en', function () {
    Route::get('about', fn () => 'English');
});
Route::when(app()->getLocale() == 'it', function () {
    Route::get('about', fn () => 'Italiano');
});
```
## License
This project is licensed under the MIT License - see the LICENSE.md file for details