Skip to content

Commit

Permalink
Update readem
Browse files Browse the repository at this point in the history
  • Loading branch information
kduma committed Jul 26, 2023
1 parent 09bd964 commit 15c324a
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
# L5-eloquent-uuidable
[![Latest Stable Version](https://poser.pugx.org/kduma/eloquent-uuidable/v/stable.svg)](https://packagist.org/packages/kduma/eloquent-uuidable)
[![Total Downloads](https://poser.pugx.org/kduma/eloquent-uuidable/downloads.svg)](https://packagist.org/packages/kduma/eloquent-uuidable)
[![Latest Unstable Version](https://poser.pugx.org/kduma/eloquent-uuidable/v/unstable.svg)](https://packagist.org/packages/kduma/eloquent-uuidable)
[![License](https://poser.pugx.org/kduma/eloquent-uuidable/license.svg)](https://packagist.org/packages/kduma/eloquent-uuidable)
# L5-eloquent-ulidable
[![Latest Stable Version](https://poser.pugx.org/kduma/eloquent-ulidable/v/stable.svg)](https://packagist.org/packages/kduma/eloquent-ulidable)
[![Total Downloads](https://poser.pugx.org/kduma/eloquent-ulidable/downloads.svg)](https://packagist.org/packages/kduma/eloquent-ulidable)
[![Latest Unstable Version](https://poser.pugx.org/kduma/eloquent-ulidable/v/unstable.svg)](https://packagist.org/packages/kduma/eloquent-ulidable)
[![License](https://poser.pugx.org/kduma/eloquent-ulidable/license.svg)](https://packagist.org/packages/kduma/eloquent-ulidable)

Eases using and generating guid's in Laravel Eloquent models.
Eases using and generating ulid's in Laravel Eloquent models.

# Setup
Install it using composer

composer require kduma/eloquent-uuidable
composer require kduma/eloquent-ulidable

# Prepare models
Inside your model (not on top of file) add following lines:

use \KDuma\Eloquent\Uuidable;
use \KDuma\Eloquent\Ulidable;

In database create `uuid` string field. If you use migrations, you can use following snippet:
In database create `ulid` string field. If you use migrations, you can use following snippet:

$table->uuid('uuid')->unique();
$table->ulid()->unique();

# Usage
By default it generates slug on first save.
By default, it generates slug on first save.

- `$model->regenerateUuid()` - Generate new uuid. (Remember to save it by yourself)
- `Model::whereUuid($uuid)->first()` - Find by guid. (`whereUuid` is query scope)

# Upgrade from 1.x/2.x version of `kduma/eloquent-guidable`

Add following line to yours models to switch from using `uuid` column name to `guid` as it was used in previous versions:

protected $uuid_field = 'guid';
- `$model->regenerateUlid()` - Generate new ulid. (Remember to save it by yourself)
- `Model::whereUlid($ulid)->first()` - Find by ulid. (`whereUlid` is query scope)

# Packagist
View this package on Packagist.org: [kduma/eloquent-uuidable](https://packagist.org/packages/kduma/eloquent-uuidable)
View this package on Packagist.org: [kduma/eloquent-ulidable](https://packagist.org/packages/kduma/eloquent-ulidable)

0 comments on commit 15c324a

Please sign in to comment.