This package is a work in progress and is not production ready.
This package allows you to set up dynamic routes for Laravel models in the database.
Features include:
- Automatically generate and store URLs for models in the database for dynamic routing.
- Remember old URLs and 301 redirect to the current one.
- Store multiple URLs with one as the main, canonical.
- Automatically update child page URLs when a parent's is updated.
- PHP >= 7.3
- Laravel >= 6.x
- oddvalue/link-builder >= 1.0.0
Via Composer
composer require oddvalue/laravel-db-router
Publish and migrate
php artisan vendor:publish --provider "Oddvalue\DbRouter\DbRouterServiceProvider"
php artisan migrate
In order to use this package your model must implement the \Oddvalue\DbRouter\Contracts\Routable
interface.
Optionally, you may use the \Oddvalue\DbRouter\Traits\HasRoutes
trait to handle most of the interface implementation for you. Using the trait requires your model to have a getRouteGeneratorClass
method that returns the fully qualified class name of the generator class for setting up the routes.
The route generator class is responsible for getting the URLs that a model is accessible from and what controller action should be performed when that URL is hit. Generators must implement the \Oddvalue\DbRouter\Contracts\RouteGenerator
interface. There is also a \Oddvalue\DbRouter\Contracts\ChildRouteGenerator
interface. Once implemented this will allow the package to also generate and update routes for child pages of your model.
The default implementation of the route generator uses oddvalue/link-builder to generate
Please see CHANGELOG for more information on what has changed recently.
$ composer test
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.