migrate to gtea from bistbucket
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\RestaurantDelivery\Traits;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
trait HasUuid
|
||||
{
|
||||
public static function bootHasUuid(): void
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
if (empty($model->uuid)) {
|
||||
$model->uuid = (string) Str::uuid();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function getRouteKeyName(): string
|
||||
{
|
||||
return 'uuid';
|
||||
}
|
||||
|
||||
public static function findByUuid(string $uuid): ?static
|
||||
{
|
||||
return static::where('uuid', $uuid)->first();
|
||||
}
|
||||
|
||||
public static function findByUuidOrFail(string $uuid): static
|
||||
{
|
||||
return static::where('uuid', $uuid)->firstOrFail();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user