Files
xin-procurement/database/factories/PurchaseOrderModelFactory.php
T
2026-07-23 20:41:25 +08:00

44 lines
1.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace Database\Factories;
use App\Models\PurchaseOrderModel;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* 采购单工厂(无需 Faker
*
* @extends Factory<PurchaseOrderModel>
*/
class PurchaseOrderModelFactory extends Factory
{
protected $model = PurchaseOrderModel::class;
private static int $sequence = 0;
public function definition(): array
{
$seq = ++self::$sequence;
return [
'purchase_no' => 'PO' . str_pad((string) $seq, 12, '0', STR_PAD_LEFT),
'purchase_date' => now()->toDateString(),
'status' => PurchaseOrderModel::STATUS_PENDING,
'total_quantity' => 0,
'total_weight' => 0,
'estimate_amount' => 0,
'actual_amount' => 0,
'operator_id' => 0,
'remark' => '',
];
}
/**
* 指定采购日期
*/
public function onDate(string $date): static
{
return $this->state(fn () => ['purchase_date' => $date]);
}
}