Advertisement
Guest User

UuidTrait

a guest
Sep 29th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1. <?php
  2.  
  3. use Rhumsaa\Uuid\Uuid;
  4.  
  5. trait UuidTrait
  6. {
  7.     /**
  8.      * Boot the Uuid trait for the model.
  9.      *
  10.      * @return void
  11.      */
  12.     public static function bootUuidTrait()
  13.     {
  14.         static::creating(function($model) {
  15.                 $model->incrementing = false;
  16.                 $model->{$model->getKeyName()} = Uuid::uuid4()->__toString();
  17.             });
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement