*/ class StoreOrderModelFactory extends Factory { protected $model = StoreOrderModel::class; private static int $sequence = 0; public function definition(): array { $seq = ++self::$sequence; return [ 'order_no' => 'SO' . str_pad((string) $seq, 12, '0', STR_PAD_LEFT), 'store_id' => 0, 'order_date' => now()->toDateString(), 'total_quantity' => 0, 'total_weight' => 0, 'total_amount' => 0, 'status' => StoreOrderModel::STATUS_PENDING, 'remark' => '', ]; } /** * 指定订货日期 */ public function onDate(string $date): static { return $this->state(fn () => ['order_date' => $date]); } /** * 已汇总(已被采购单归集) */ public function summarized(): static { return $this->state(fn () => ['status' => StoreOrderModel::STATUS_SUMMARIZED]); } }