feat: User model

This commit is contained in:
b1ek 2024-08-29 19:48:10 +10:00
parent 837a1ffa5b
commit f32cb1832a
Signed by: blek
GPG Key ID: 14546221E3595D0C
3 changed files with 26 additions and 1 deletions

View File

@ -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',
];
/**

20
app/UuidId.php Normal file
View File

@ -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';
}
}

View File

@ -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();