Download the PHP package intervention/eloquent-hashid without Composer
On this page you can find all versions of the php package intervention/eloquent-hashid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download intervention/eloquent-hashid
More information about intervention/eloquent-hashid
Files in intervention/eloquent-hashid
Package eloquent-hashid
Short Description Configurable HashId Trait for Laravel Eloquent models
License MIT
Homepage http://intervention.io/
Informations about the package eloquent-hashid
Intervention Eloquent HashID
This package provides a trait to easily encode and decode hashids in your Eloquent models. Every model gets an attribute and a scope for hashid queries.
Installation
You can install this package with Composer.
Require the package via Composer:
$ composer require intervention/eloquent-hashid
Laravel will automatically discover the packages service provider class.
Setup
After installation you're able to publish the configuration file to your Laravel application with the following command.
$ php artisan vendor:publish --provider="Intervention\EloquentHashid\Laravel\EloquentHashidServiceProvider"
You will find a new config file in config/hashid.php
, which you can customize. I strongly suggest to change at least the salt_prefix
option to your own value.
Now you can include the trait Intervention\EloquentHashid\HasHashid
in your Eloquent Model to add the hashid features.
Usage
Code Example
Every Eloquent Model gets a new hashid
attribute, which is created based on the models classname, the key and the salt prefix. You're also able to query models with the now added hashid()
scope.
Access hashid attribute
Query models
Route Model Binding
Eloquent models can be resolved by their hashid in routes by defining a custom key.
Authors
This library is developed and maintained by Oliver Vogel
License
Intervention Eloquent HashID is licensed under the MIT License.