Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-daneshvar authored Jun 26, 2019
1 parent 2aa4f72 commit f672f6a
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
Automatically persist Hashids on your newly created Eloquent models
using Ivan Akimov's [Hashids library](https://github.com/ivanakimov/hashids.php).

This can be useful when you need to generate a unique alphanumeric (or any character) combinations
This can be useful when you need to generate a unique alphanumeric (or any other character) combinations
to represent your models.

## Installation

Require the package using composer:
Require the package using composer.

```bash
composer require matt-daneshvar/eloquent-hashids
Expand Down Expand Up @@ -78,6 +78,31 @@ class Receipt extends Model
}
```

### Changing the Hashid column
To customize the hashid column, set your own custom `$hashidColumn` value on your model.
```php
class Receipt extends Model
{
use Hashid;

protected static $hashidColumn = 'uid';
}
```

### Changing the salt
Each model's table name is by default used as the salt for generating Hashids.
With that, models of separate classes that share the same IDs
(e.g. a `Task` model with ID of 1 and a `Receipt` model also with ID of 1) would each have different Hashids.
You may change this behaviour and override the salt by specifying the `$hashidSlat` on your model.
```php
class Receipt extends Model
{
use Hashid;

protected static $hashidSalt = 'salt and pepper';
}
```

### Creating your own Hashids instance
To fully customize the behaviour of the underlying Hashids library,
you may also define your own `Hashids` instance in your model's boot method.
Expand Down

0 comments on commit f672f6a

Please sign in to comment.