From f32cb1832afa3a28085de3ce06a757f06b7a0515 Mon Sep 17 00:00:00 2001 From: b1ek Date: Thu, 29 Aug 2024 19:48:10 +1000 Subject: [PATCH] feat: User model --- app/Models/User.php | 6 +++++- app/UuidId.php | 20 +++++++++++++++++++ .../0001_01_01_000000_create_users_table.php | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 app/UuidId.php diff --git a/app/Models/User.php b/app/Models/User.php index 715208a..c0eb53e 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -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', ]; /** diff --git a/app/UuidId.php b/app/UuidId.php new file mode 100644 index 0000000..281db7c --- /dev/null +++ b/app/UuidId.php @@ -0,0 +1,20 @@ +id = Uuid::uuid6()->toString(); + }); + } + public function getIncrementing(): bool { + return false; + } + public function getKeyType(): string { + return 'string'; + } +} diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index dc21c93..8236a0e 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -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();