first&last
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Models\Department;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$serviceDepartment = Department::query()->where('name', 'Сервисный отдел')->first();
|
||||
$helpdeskDepartment = Department::query()->where('name', 'IT Helpdesk')->first();
|
||||
|
||||
User::query()->updateOrCreate(
|
||||
['email' => 'admin@service.local'],
|
||||
[
|
||||
'name' => 'Главный администратор',
|
||||
'password' => Hash::make('password'),
|
||||
'role' => UserRole::ADMIN,
|
||||
'phone' => '+79990000001',
|
||||
'department_id' => $helpdeskDepartment?->id,
|
||||
'is_active' => true,
|
||||
'email_verified_at' => now(),
|
||||
]
|
||||
);
|
||||
|
||||
User::query()->updateOrCreate(
|
||||
['email' => 'manager@service.local'],
|
||||
[
|
||||
'name' => 'Сервис-менеджер',
|
||||
'password' => Hash::make('password'),
|
||||
'role' => UserRole::MANAGER,
|
||||
'phone' => '+79990000002',
|
||||
'department_id' => $serviceDepartment?->id,
|
||||
'is_active' => true,
|
||||
'email_verified_at' => now(),
|
||||
]
|
||||
);
|
||||
|
||||
$technicians = [
|
||||
['name' => 'Иван Петров', 'email' => 'tech1@service.local'],
|
||||
['name' => 'Алексей Сидоров', 'email' => 'tech2@service.local'],
|
||||
['name' => 'Ольга Смирнова', 'email' => 'tech3@service.local'],
|
||||
];
|
||||
|
||||
foreach ($technicians as $technician) {
|
||||
User::query()->updateOrCreate(
|
||||
['email' => $technician['email']],
|
||||
[
|
||||
'name' => $technician['name'],
|
||||
'password' => Hash::make('password'),
|
||||
'role' => UserRole::TECHNICIAN,
|
||||
'phone' => '+7999'.fake()->numerify('######'),
|
||||
'department_id' => $serviceDepartment?->id,
|
||||
'is_active' => true,
|
||||
'email_verified_at' => now(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
User::query()->updateOrCreate(
|
||||
['email' => "client{$i}@service.local"],
|
||||
[
|
||||
'name' => "Клиент {$i}",
|
||||
'password' => Hash::make('password'),
|
||||
'role' => UserRole::CLIENT,
|
||||
'phone' => '+7991'.str_pad((string) $i, 6, '0', STR_PAD_LEFT),
|
||||
'department_id' => null,
|
||||
'is_active' => true,
|
||||
'email_verified_at' => now(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user