<?php

namespace Database\Seeders;

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

class UserSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $user1 = User::create([
            'first_name' => 'Jasurbek',
            'last_name' => 'Abdurakhmonov',
            'password' => 'qwerty56',
            'role_id' => 1,
            'phone' => '998998973290',
        ]);

        // create legal user
        $user1->legalInfo()->create([
            'company_name' => 'Ulasoft',
            'inn' => '123456789',
            'bank_name' => 'Orient Finans Bank',
            'mfo' => '123456',
            'oked' => '12345678',
            'payment_account' => '12345678901234567890',
            'address' => 'Tashkent',
            'email' => 'example@gmail.com',
            'phone' => '998971234567',
        ]);

        Address::create([
            'user_id' => $user1->id,
            'city_id' => 1,
            'address' => 'Tashkent',
            'home' => '12',
            'landmark' => 'Tashkent city',
        ]);

        // create orders
        $user1->orders()->create([
            'branch_id' => 1,
            'client_type' => 'legal',
            'full_name' => 'Jasurbek Abdurakhmonov',
            'phone' => '998998973290',
            'legal_id' => 1,
            'address_id' => 1,
            'with_installation' => true,
            'payment_type' => 'cash',
            'with_didox' => true,
            'delivery_type' => 'delivery',
            'shipment_date' => now(),
            'accepted_at' => now(),
            'currency' => json_encode(['currency' => 'UZS', 'rate' => 1]),
            'status' => 'processing',
            'payment_status' => 'waiting',
            'price_products' => 160_000,
            'price_delivery' => 20_000,
            'price_total' => 230_000,
            'price_master' => 50_000,
        ]);

        OrderProducts::create([
            'order_id' => 1,
            'product_id' => 1,
            'price' => 100_000,
            'count' => 1,
            'discount' => null,
        ]);

        OrderProducts::create([
            'order_id' => 1,
            'product_id' => 2,
            'price' => 35_000,
            'count' => 2,
            'discount' => 30_000,
        ]);
    }
}
