kduma/eloquent-guidable

This package is abandoned and no longer maintained. The author suggests using the kduma/eloquent-uuidable package instead.

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

2.01 2016-10-05 15:12 UTC

This package is not auto-updated.

Last update: 2022-12-02 01:34:21 UTC


README

For new apps, please use the newer version available here: kduma/eloquent-uuidable

L5-eloquent-guidable

Latest Stable Version Total Downloads Latest Unstable Version License SensioLabsInsight StyleCI

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

Setup

Add the package to the require section of your composer.json and run composer update

"kduma/eloquent-guidable": "^1.1"

Prepare models

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

use \KDuma\Eloquent\Guidable;

In database create guid string field. If you use migrations, you can use following snippet:

$table->string('guid')->unique();

Usage

By default it generates slug on first save.

  • $model->newGuid() - Generate new guid. (Remember to save it by yourself)
  • Model::whereGuid($slug)->first() - Find by guid. (whereGuid is query scope)

Packagist

View this package on Packagist.org: kduma/eloquent-guidable