<?php

namespace Database\Factories;

use App\Models\Purchase;
use App\Models\Warehouse;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

class PurchaseFactory extends Factory
{
    protected $model = Purchase::class;

    public function definition(): array
    {
        return [
            'warehouse_id' => Warehouse::factory(),
            'invoice_number' => Str::upper($this->faker->bothify('PO-########')),
            'purchase_date' => $this->faker->date(),
            'total' => $this->faker->numberBetween(50000, 500000),
            'note' => $this->faker->optional()->sentence(6),
        ];
    }

    public function today(): Factory
    {
        return $this->state(fn () => ['created_at' => now()]);
    }

    public function yesterday(): Factory
    {
        return $this->state(fn () => ['created_at' => now()->subDay()]);
    }
}
