Remove Faker usage from seeders

This commit is contained in:
2026-06-03 06:50:21 +05:00
parent 177c316b44
commit 932b37c7f6
4 changed files with 134 additions and 69 deletions
+17 -2
View File
@@ -14,13 +14,28 @@ class ActivityLogSeeder extends Seeder
$users = User::query()->get();
$requests = ServiceRequest::query()->latest()->limit(10)->get();
$actions = ['updated', 'assigned', 'status_changed'];
$descriptions = [
'Изменены параметры заявки.',
'Заявка назначена ответственному специалисту.',
'Изменен статус обработки заявки.',
'Добавлено служебное действие по заявке.',
];
ActivityLog::query()
->where('model_type', ServiceRequest::class)
->whereIn('action', $actions)
->where('ip_address', '127.0.0.1')
->delete();
foreach ($requests as $request) {
ActivityLog::query()->create([
'user_id' => $users->random()->id,
'model_type' => ServiceRequest::class,
'model_id' => $request->id,
'action' => fake()->randomElement(['updated', 'assigned', 'status_changed']),
'description' => fake()->sentence(),
'action' => $actions[array_rand($actions)],
'description' => $descriptions[array_rand($descriptions)],
'ip_address' => '127.0.0.1',
'created_at' => now()->subHours(rand(1, 72)),
]);