move traits into their own namespace

This commit is contained in:
Nabeel Shahzad
2017-08-12 12:24:00 -05:00
parent 2e128cb8c7
commit b817760276
3 changed files with 4 additions and 1 deletions

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Models\Traits;
use Webpatser\Uuid\Uuid;
trait Uuids
{
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
$key = $model->getKeyName();
if (empty($model->{$key})) {
$model->{$key} = Uuid::generate()->string;
}
#$model->{$model->getKeyName()} = Uuid::generate()->string;
});
}
}