generated from liutk/owl-admin-base
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Enums\ComplaintStatus;
|
|
use App\Models\Complaint;
|
|
use App\Models\Employee;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class ComplaintSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$timestamp = now();
|
|
|
|
/** @var \Illuminate\Database\Eloquent\Collection */
|
|
$employees = Employee::pluck('id');
|
|
|
|
Complaint::insert(
|
|
collect([])
|
|
->merge(Complaint::factory()->count(5)->make())
|
|
->merge(Complaint::factory()->count(5)->state(['anonymous' => true])->make())
|
|
->merge(Complaint::factory()->count(5)->state(['complaint_status' => ComplaintStatus::Processing])->make())
|
|
->merge(Complaint::factory()->count(5)->processed()->make())
|
|
->map(function (Complaint $instance) use ($timestamp, $employees) {
|
|
return array_merge($instance->toArray(), [
|
|
'employee_id' => $employees->random(),
|
|
'created_at' => $timestamp,
|
|
'updated_at' => $timestamp,
|
|
]);
|
|
})
|
|
->all()
|
|
);
|
|
}
|
|
}
|