Remove Faker usage from seeders
This commit is contained in:
@@ -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)),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user