Skip to content

Commit

Permalink
Merge branch 'master' of github.com:binarycabin/laravel-uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
kilrizzy committed Mar 8, 2019
2 parents 136170f + b91c159 commit 0d1d017
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/Traits/HasUUID.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ trait HasUUID
{
public static function bootHasUUID()
{
static::creating(function($model) {
static::creating(function ($model) {
$uuidFieldName = $model->getUUIDFieldName();
if(empty($model->$uuidFieldName)){
if (empty($model->$uuidFieldName)) {
$model->$uuidFieldName = static::generateUUID();
}
});
}

public function getUUIDFieldName()
{
if(!empty($this->uuidFieldName)){
if (! empty($this->uuidFieldName)) {
return $this->uuidFieldName;
}

return 'uuid';
}

Expand All @@ -36,5 +37,4 @@ public static function findByUuid($uuid)
{
return static::byUUID($uuid)->first();
}

}
}
4 changes: 1 addition & 3 deletions tests/HasUUIDTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

class HasUUIDTest extends TestCase
{

public function test_coming_soon()
{
$this->assertTrue(true);
}

}
}

0 comments on commit 0d1d017

Please sign in to comment.