user profiles

This commit is contained in:
2026-02-06 14:33:11 +02:00
parent d458e36f4f
commit b2fd2a5eac
20 changed files with 3936 additions and 9 deletions
+5 -5
View File
@@ -15,11 +15,11 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// User::factory(10)->create();
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
$this->call([
RoleSeeder::class,
]);
// Uncomment to create additional users with factory
// User::factory(10)->create();
}
}
+74
View File
@@ -0,0 +1,74 @@
<?php
namespace Database\Seeders;
use App\Models\Role;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class RoleSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// Create roles
$adminRole = Role::create([
'name' => 'Admin',
'slug' => 'admin',
'description' => 'Full access to all features and settings',
]);
$moderatorRole = Role::create([
'name' => 'Moderator',
'slug' => 'moderator',
'description' => 'Can approve/reject products and delete comments',
]);
$userRole = Role::create([
'name' => 'User',
'slug' => 'user',
'description' => 'Can submit products, upvote, and comment',
]);
// Create test users
$admin = User::create([
'name' => 'Admin User',
'email' => 'admin@example.com',
'password' => Hash::make('password'),
'bio' => 'Administrator of the platform',
'email_verified_at' => now(),
]);
$admin->roles()->attach($adminRole);
$moderator = User::create([
'name' => 'Moderator User',
'email' => 'moderator@example.com',
'password' => Hash::make('password'),
'bio' => 'Content moderator',
'email_verified_at' => now(),
]);
$moderator->roles()->attach($moderatorRole);
$regularUser = User::create([
'name' => 'Regular User',
'email' => 'user@example.com',
'password' => Hash::make('password'),
'bio' => 'Regular platform user',
'website' => 'https://example.com',
'twitter' => 'example',
'github' => 'example',
'linkedin' => 'example',
'email_verified_at' => now(),
]);
$regularUser->roles()->attach($userRole);
$this->command->info('Roles and test users created successfully!');
$this->command->info('Admin: admin@example.com / password');
$this->command->info('Moderator: moderator@example.com / password');
$this->command->info('User: user@example.com / password');
}
}