OrderModelFactory.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | Model Factories
  5. |--------------------------------------------------------------------------
  6. |
  7. | Here you may define all of your model factories. Model factories give
  8. | you a convenient way to create models for testing and seeding your
  9. | database. Just tell the factory how a default model should look.
  10. |
  11. */
  12. /** @var \Illuminate\Database\Eloquent\Factory $factory */
  13. use App\Shop\Addresses\Address;
  14. use App\Shop\Cities\City;
  15. use App\Shop\Couriers\Courier;
  16. use App\Shop\Customers\Customer;
  17. use App\Shop\Orders\Order;
  18. use App\Shop\OrderStatuses\OrderStatus;
  19. $factory->define(Order::class, function (Faker\Generator $faker) {
  20. $courier = factory(Courier::class)->create();
  21. $customer = factory(Customer::class)->create();
  22. $city = factory(City::class)->create();
  23. $address = factory(Address::class)->create([
  24. 'country_id' => 1,
  25. 'city' => $city->name,
  26. 'customer_id' => $customer->id
  27. ]);
  28. $os = factory(OrderStatus::class)->create();
  29. return [
  30. 'reference' => $faker->uuid,
  31. 'courier_id' => $courier->id,
  32. 'customer_id' => $customer->id,
  33. 'address_id' => $address->id,
  34. 'order_status_id' => $os->id,
  35. 'payment' => 'paypal',
  36. 'discounts' => $faker->randomFloat(2, 10, 999),
  37. 'total_products' => $faker->randomFloat(2, 10, 5555),
  38. 'tax' => $faker->randomFloat(2, 10, 9999),
  39. 'total' => $faker->randomFloat(2, 10, 9999),
  40. 'total_paid' => $faker->randomFloat(2, 10, 9999),
  41. 'invoice' => null,
  42. ];
  43. });