<?php

namespace Database\Seeders;

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

class PriceSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Practice::chunk(100, function ($chunkedPractitionerRoles) {
            foreach ($chunkedPractitionerRoles as $practitionerRole) {

                if ($practitionerRole->service_code === 'instant-chat') {
                    $price = 20000;
                } elseif ($practitionerRole->service_code === 'chat') {
                    $price = 50000;
                } elseif ($practitionerRole->service_code === 'video') {
                    $price = 70000;
                } elseif ($practitionerRole->service_code === 'walkin') {
                    $price = 90000;
                }

                $practitionerRole->prices()->insert([
                    'priceable_type' => 'App\Models\Practice',
                    'priceable_id' => $practitionerRole->id,
                    'price_group_id' => 1,
                    'price_gross' => $price,
                    'price_net' => $price,
                    'has_tax' => 0,
                    'discount_type' => 'percentage',
                    'discount_percentage' => '',
                    'discount_absolute' => ''
                ]);
            }
        });
    }
}
