64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Database\Factories;
|
||
|
|
|
||
|
|
use App\Models\Orders\Order;
|
||
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @extends Factory<Order>
|
||
|
|
*/
|
||
|
|
class OrderFactory extends Factory
|
||
|
|
{
|
||
|
|
protected $model = Order::class;
|
||
|
|
|
||
|
|
public function definition(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'order_no' => 'ORD-'.fake()->unique()->numerify('######'),
|
||
|
|
'order_type_code' => Order::TYPE_ORDER,
|
||
|
|
'status_code' => Order::STATUS_DRAFT,
|
||
|
|
'site_name' => fake()->company().' 현장',
|
||
|
|
'quantity' => fake()->numberBetween(1, 100),
|
||
|
|
'supply_amount' => fake()->numberBetween(100000, 10000000),
|
||
|
|
'tax_amount' => 0,
|
||
|
|
'total_amount' => 0,
|
||
|
|
'received_at' => now(),
|
||
|
|
'delivery_date' => now()->addDays(14),
|
||
|
|
'memo' => fake()->optional()->sentence(),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 확정 상태
|
||
|
|
*/
|
||
|
|
public function confirmed(): static
|
||
|
|
{
|
||
|
|
return $this->state(['status_code' => Order::STATUS_CONFIRMED]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 생산중 상태
|
||
|
|
*/
|
||
|
|
public function inProduction(): static
|
||
|
|
{
|
||
|
|
return $this->state(['status_code' => Order::STATUS_IN_PRODUCTION]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 완료 상태
|
||
|
|
*/
|
||
|
|
public function completed(): static
|
||
|
|
{
|
||
|
|
return $this->state(['status_code' => Order::STATUS_COMPLETED]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 취소 상태
|
||
|
|
*/
|
||
|
|
public function cancelled(): static
|
||
|
|
{
|
||
|
|
return $this->state(['status_code' => Order::STATUS_CANCELLED]);
|
||
|
|
}
|
||
|
|
}
|