|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Database\Factories;
|
|
|
|
|
|
|
|
use App\Enums\OrderStatus;
|
|
|
|
use App\Enums\OrderType;
|
|
|
|
use App\Models\Order;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
use Illuminate\Support\Carbon;
|
|
|
|
|
|
|
|
class OrderFactory extends Factory
|
|
|
|
{
|
|
|
|
protected $model = Order::class;
|
|
|
|
|
|
|
|
public function definition(): array
|
|
|
|
{
|
|
|
|
$order_date = Carbon::today()->subDays(rand(0, 60));
|
|
|
|
$due_date = $order_date->copy()->addDays(rand(7, 12));
|
|
|
|
|
|
|
|
$status = $due_date < today() ?
|
|
|
|
OrderStatus::INVOICED->value :
|
|
|
|
$this->faker->randomElement(OrderStatus::cases())->value;
|
|
|
|
|
|
|
|
return [
|
|
|
|
'created_at' => $order_date,
|
|
|
|
'updated_at' => Carbon::now(),
|
|
|
|
|
|
|
|
'customer_po' => $this->faker->randomElement([
|
|
|
|
$this->faker->randomNumber(6, true),
|
|
|
|
$this->faker->words(rand(2, 6), true),
|
|
|
|
]),
|
|
|
|
|
|
|
|
'order_type' => $this->faker->randomElement(OrderType::cases())->value,
|
|
|
|
'order_date' => $order_date,
|
|
|
|
'due_date' => $due_date,
|
|
|
|
'status' => $status,
|
|
|
|
'notes' => $this->faker->words(10, true),
|
|
|
|
|
|
|
|
'rush' => $this->faker->boolean(20),
|
|
|
|
'repeat' => $this->faker->boolean(),
|
|
|
|
'new_art' => $this->faker->boolean(),
|
|
|
|
'event' => $this->faker->boolean(),
|
|
|
|
'digitizing' => $this->faker->boolean(),
|
|
|
|
'garments' => $this->faker->boolean(),
|
|
|
|
'supplied_file' => $this->faker->boolean(),
|
|
|
|
|
|
|
|
'printed' => $this->faker->boolean(),
|
|
|
|
'pre_production' => $this->faker->boolean(),
|
|
|
|
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|