Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use Rhumsaa\Uuid\Uuid;
- trait UuidTrait
- {
- /**
- * Boot the Uuid trait for the model.
- *
- * @return void
- */
- public static function bootUuidTrait()
- {
- static::creating(function($model) {
- $model->incrementing = false;
- $model->{$model->getKeyName()} = Uuid::uuid4()->__toString();
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement