Last active
December 24, 2022 15:27
-
-
Save AbiruzzamanMolla/69e9a92272e437046ed529d000f919b8 to your computer and use it in GitHub Desktop.
uuid laraevl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Ramsey\Uuid\Uuid; | |
class Foo extends Model | |
{ | |
protected $primaryKey = 'uuid'; | |
protected $keyType = 'string'; | |
public $incrementing = false; | |
protected static function boot() | |
{ | |
parent::boot(); | |
static::creating(function (Model $model) { | |
$model->setAttribute($model->getKeyName(), Uuid::uuid4()); | |
}); | |
} | |
} | |
https://laracasts.com/discuss/channels/laravel/uuid-as-primary-key-type | |
https://fakerphp.github.io/formatters/image/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment