feat: User model
This commit is contained in:
parent
837a1ffa5b
commit
f32cb1832a
|
@ -3,13 +3,15 @@
|
|||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use App\UuidId;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Infocyph\UID\UUID;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasFactory, Notifiable;
|
||||
use HasFactory, Notifiable, UuidId;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
@ -21,6 +23,8 @@ class User extends Authenticatable
|
|||
'name',
|
||||
'middle_name',
|
||||
'email',
|
||||
'phone',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
trait UuidId
|
||||
{
|
||||
protected static function boot() {
|
||||
parent::boot();
|
||||
static::creating(function ($model) {
|
||||
$model->id = Uuid::uuid6()->toString();
|
||||
});
|
||||
}
|
||||
public function getIncrementing(): bool {
|
||||
return false;
|
||||
}
|
||||
public function getKeyType(): string {
|
||||
return 'string';
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ return new class extends Migration
|
|||
$table->string('name');
|
||||
$table->string('middle_name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('phone');
|
||||
$table->string('password');
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->rememberToken();
|
||||
|
|
Loading…
Reference in New Issue