CategoryModelFactory.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\Categories\Category;
  14. use Illuminate\Http\UploadedFile;
  15. $factory->define(Category::class, function (Faker\Generator $faker) {
  16. $name = $faker->unique()->randomElement([
  17. 'Gear',
  18. 'Clothing',
  19. 'Shoes',
  20. 'Diapering',
  21. 'Feeding',
  22. 'Bath',
  23. 'Toys',
  24. 'Nursery',
  25. 'Household',
  26. 'Grocery'
  27. ]);
  28. $file = UploadedFile::fake()->image('category.png', 600, 600);
  29. return [
  30. 'name' => $name,
  31. 'slug' => str_slug($name),
  32. 'description' => $faker->paragraph,
  33. 'cover' => $file->store('categories', ['disk' => 'public']),
  34. 'status' => 1
  35. ];
  36. });