<?php

namespace Database\Seeders;

use App\Models\User;
use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{

    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        User::factory()->create([
            'name' => 'Sterna Admin',
            'username' => 'admin',
            'role' => \App\Enums\UserRole::Admin,
        ]);

        User::factory()->create([
            'name' => 'Sterna Techničar',
            'username' => 'tehnicar',
            'role' => \App\Enums\UserRole::Technician,
        ]);

        $aps = \App\Models\Client::factory()->create([
            'name' => 'АПС',
            'address' => 'Бул. Партизански одреди 14А, Скопје',
            'phone' => '070247257',
        ]);

        $apsPrinter = \App\Models\Printer::factory()->make([
            'client_id' => $aps->id,
            'manufacturer' => 'RICOH',
            'model' => 'MP C4503',
            'serial_number' => 'E174M630497',
            'installation_date' => '2020-07-10',
            'status' => 'active',
        ]);
        $apsPrinter->save();

        foreach ([
            ['reading_date' => '2020-07-10', 'bw_counter' => 105543, 'color_counter' => 40189, 'scan_counter' => 7172, 'toner_black' => 3, 'toner_cyan' => 2, 'toner_magenta' => 1, 'toner_yellow' => 2],
            ['reading_date' => '2020-11-02', 'bw_counter' => 105936, 'color_counter' => 40414, 'scan_counter' => 7255],
            ['reading_date' => '2020-12-03', 'bw_counter' => 106090, 'color_counter' => 40592, 'scan_counter' => 7303],
        ] as $r) {
            $apsPrinter->readings()->create($r);
        }
    }
}
