<?php

namespace Database\Factories;

use App\Models\Purchase;
use App\Models\PurchaseItem;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

class PurchaseItemFactory extends Factory
{
    protected $model = PurchaseItem::class;

    public function definition(): array
    {
        $unitPrice = $this->faker->numberBetween(10000, 100000);
        $quantity = $this->faker->numberBetween(1, 10);

        return [
            'purchase_id' => Purchase::factory(),
            'user_id' => User::factory(),
            'purchasable_type' => null,
            'purchasable_id' => null,
            'quantity' => $quantity,
            'unit_price' => $unitPrice,
            'total_price' => $unitPrice * $quantity,
        ];
    }
}
