ProductModelFactory.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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\Products\Product;
  14. use Illuminate\Http\UploadedFile;
  15. $factory->define(Product::class, function (Faker\Generator $faker) {
  16. $product = $faker->unique()->sentence;
  17. $file = UploadedFile::fake()->image('product.png', 600, 600);
  18. return [
  19. 'sku' => $this->faker->numberBetween(1111111, 999999),
  20. 'name' => $product,
  21. 'slug' => str_slug($product),
  22. 'description' => $this->faker->paragraph,
  23. 'cover' => $file->store('products', ['disk' => 'public']),
  24. 'quantity' => 10,
  25. 'price' => 5.00,
  26. 'status' => 1,
  27. 'weight' => 5,
  28. 'mass_unit' => config('shop.weight', 'gms')
  29. ];
  30. });