You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
PHP
<?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, 30));
|
|
$due_date = $order_date->copy()->addDays(rand(9, 15));
|
|
|
|
return [
|
|
'created_at' => $order_date,
|
|
'updated_at' => Carbon::now(),
|
|
'customer_po' => $this->faker->randomNumber(6, true),
|
|
'order_type' => $this->faker->randomElement(OrderType::cases())->value,
|
|
'order_date' => $order_date,
|
|
'due_date' => $due_date,
|
|
'status' => $this->faker->randomElement(OrderStatus::cases())->value,
|
|
'notes' => $this->faker->words(10, true),
|
|
'order_attributes' => ['New Art', 'Garments', 'Rush'],
|
|
];
|
|
}
|
|
}
|