| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
-
- namespace Database\Factories;
-
- use App\Enums\OrderStatus;
- use App\Models\Order;
- use App\Models\Store;
- use Illuminate\Database\Eloquent\Factories\Factory;
- use Illuminate\Support\Str;
-
- /**
- * @extends Factory<Order>
- */
- class OrderFactory extends Factory
- {
- /**
- * @return array<string, mixed>
- */
- public function definition(): array
- {
- return [
- 'store_id' => Store::factory(),
- 'public_id' => fn () => (string) Str::ulid(),
- 'number' => fake()->unique()->numberBetween(1001, 999999),
- 'status' => OrderStatus::Pending,
- 'customer_name' => 'Aminah binti Ali',
- 'customer_email' => 'aminah@example.com',
- 'customer_phone' => '0123456789',
- 'shipping_address' => [
- 'line1' => '12 Jalan Mawar',
- 'line2' => null,
- 'city' => 'Shah Alam',
- 'postcode' => '40000',
- 'state' => 'Selangor',
- 'country' => 'MY',
- ],
- 'subtotal' => 2580,
- 'shipping_total' => 0,
- 'total' => 2580,
- 'currency' => 'MYR',
- ];
- }
-
- public function paid(): static
- {
- return $this->state(['status' => OrderStatus::Paid, 'paid_at' => now(), 'payment_reference' => 'pi_test']);
- }
- }
|