Download the PHP package touhidurabir/laravel-multi-key-route-binding without Composer
On this page you can find all versions of the php package touhidurabir/laravel-multi-key-route-binding. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download touhidurabir/laravel-multi-key-route-binding
More information about touhidurabir/laravel-multi-key-route-binding
Files in touhidurabir/laravel-multi-key-route-binding
Package laravel-multi-key-route-binding
Short Description A simple laravel package to handle multiple key based model route binding
License MIT
Informations about the package laravel-multi-key-route-binding
Laravel Multi Key Route Binding
A simple package to handle the multiple key/column based route model binding for laravel package
Installation
Require the package using composer:
Usage
Use the trait HasMultipleRouteBindingKeys in model where uuid needed to attach
And then add the protected property $routeBindingKeys which will contails the list of other route binding keys.
By default column id is considered as the primary key for route model binding . But it is always possible to override/customize the primary key for route binding as per laravel doc
The extra keys are used for implicit route model binding, including routes using ->withTrashed() and scoped child bindings (for example /users/{user}/posts/{post} with ->scopeBindings(), where the lookup stays scoped to the parent). When a route names an explicit binding field, such as {user:email}, only that field is used.
By default the trait returns id from getRouteKeyName(), even when the model has a different primary key. To use the model's own route key name instead (its primary key, for example uuid or code), opt in with the $useModelRouteKeyName property:
The MultiKyeRouteBinding facade resolves a model the same way route model binding does, which is handy outside of routes:
The package also provide a bit of safe guard by checking if the model table has the given binding key column .
If the binding key column not found for model table schema, it will skip that binding key.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
MIT