update user

This commit is contained in:
Toy Rik 2026-01-22 14:55:22 +03:00
parent 69160bd4fb
commit 40ba7450e6
5 changed files with 40 additions and 14 deletions

View File

@ -20,14 +20,15 @@ LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=
# DB_CONNECTION=sqlite
DB_CONNECTION=pgsql
DB_HOST=postgres
DB_PORT=5432
DB_DATABASE=js-manager
DB_USERNAME=user
DB_PASSWORD=password
SESSION_DRIVER=database
SESSION_DRIVER=redis
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/

View File

@ -3,6 +3,9 @@
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
@ -10,7 +13,9 @@ use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
use Notifiable;
use HasUuids;
use HasFactory;
/**
* The attributes that are mass assignable.
@ -33,6 +38,8 @@ class User extends Authenticatable
'remember_token',
];
protected $primaryKey = 'uuid';
/**
* Get the attributes that should be cast.
*

View File

@ -12,7 +12,7 @@ return new class extends Migration
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->uuid()->primary();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();

View File

@ -15,11 +15,8 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// User::factory(10)->create();
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
$this->call([
UserSeeder::class,
]);
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
class UserSeeder extends Seeder
{
public function run(): void
{
if (!User::where('name', 'admin')->exists()) {
User::factory()->create([
'name' => 'admin',
'email' => 'admin@example.com',
'password' => bcrypt('password'),
]);
}
User::factory(10)->create();
}
}