A simple drop-in solution for providing UUID and ULID support for the IDs of your Eloquent models.
composer require brokeyourbike/uid-keys
use Illuminate\Database\Eloquent\Model;
use BrokeYourBike\UidKeys\Database\Eloquent\Ulid;
class ExampleModel extends Model
{
use Ulid;
/**
* The "type" of the auto-incrementing ID.
*
* @var string
*/
protected $keyType = 'string';
/**
* Indicates if the IDs are auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
}
Code mainly stolen from the goldspecdigital/laravel-eloquent-uuid package.
- Ivan Stasiuk | Twitter | LinkedIn | stasi.uk