Add avatars, profiles, and auth flows
This commit is contained in:
@@ -23,8 +23,11 @@ class UserFactory extends Factory
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->unique()->userName();
|
||||
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'name' => $name,
|
||||
'name_canonical' => Str::lower($name),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('name_canonical')->nullable()->after('name');
|
||||
});
|
||||
|
||||
DB::table('users')
|
||||
->whereNull('name_canonical')
|
||||
->update(['name_canonical' => DB::raw('lower(name)')]);
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->unique('name_canonical');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropUnique(['name_canonical']);
|
||||
$table->dropColumn('name_canonical');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('avatar_path')->nullable()->after('name_canonical');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('avatar_path');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -4,6 +4,7 @@ namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
|
||||
@@ -14,14 +15,25 @@ class UserSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$adminRole = Role::where('name', 'ROLE_ADMIN')->first();
|
||||
$userRole = Role::where('name', 'ROLE_USER')->first();
|
||||
$adminRole = Role::where(column: 'name', operator: 'ROLE_ADMIN')->first();
|
||||
$userRole = Role::where(column: 'name', operator: 'ROLE_USER')->first();
|
||||
|
||||
$admin = User::firstOrCreate(
|
||||
['email' => 'tracer@24unix.net'],
|
||||
[
|
||||
$admin = User::updateOrCreate(
|
||||
attributes: ['email' => 'tracer@24unix.net'],
|
||||
values : [
|
||||
'name' => 'tracer',
|
||||
'password' => Hash::make('password'),
|
||||
'name_canonical' => Str::lower('tracer'),
|
||||
'password' => Hash::make(value: 'password'),
|
||||
'email_verified_at' => now(),
|
||||
]
|
||||
);
|
||||
|
||||
$micha = User::updateOrCreate(
|
||||
attributes: ['email' => 'micha@24unix.net'],
|
||||
values : [
|
||||
'name' => 'Micha',
|
||||
'name_canonical' => Str::lower('Micha'),
|
||||
'password' => Hash::make(value: 'password'),
|
||||
'email_verified_at' => now(),
|
||||
]
|
||||
);
|
||||
@@ -34,6 +46,10 @@ class UserSeeder extends Seeder
|
||||
$admin->roles()->syncWithoutDetaching([$userRole->id]);
|
||||
}
|
||||
|
||||
if ($userRole) {
|
||||
$micha->roles()->syncWithoutDetaching([$userRole->id]);
|
||||
}
|
||||
|
||||
$users = User::factory()->count(100)->create([
|
||||
'email_verified_at' => now(),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user