Skip to content

Commit 78e2eb8

Browse files
committed
Add product factory
1 parent 745c057 commit 78e2eb8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

database/factories/ProductFactory.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use App\Models\Product;
66
use Illuminate\Database\Eloquent\Factories\Factory;
7+
use Illuminate\Support\Arr;
8+
use Illuminate\Support\Str;
79

810
class ProductFactory extends Factory
911
{
@@ -21,8 +23,14 @@ class ProductFactory extends Factory
2123
*/
2224
public function definition()
2325
{
26+
$productPrefixes = ['Sweater', 'Pants', 'Shirt', 'Hat', 'Glasses', 'Socks'];
27+
$name = $this->faker->company . ' ' . Arr::random($productPrefixes);
28+
2429
return [
25-
//
30+
'name' => $name,
31+
'slug' => Str::slug($name),
32+
'description' => $this->faker->realText(320),
33+
'price' => $this->faker->numberBetween(10000, 100000),
2634
];
2735
}
2836
}

0 commit comments

Comments
 (0)