File tree Expand file tree Collapse file tree 3 files changed +64
-1
lines changed Expand file tree Collapse file tree 3 files changed +64
-1
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Database \Factories ;
4+
5+ use App \Models \Category ;
6+ use Illuminate \Database \Eloquent \Factories \Factory ;
7+ use Illuminate \Support \Str ;
8+
9+ class CategoryFactory extends Factory
10+ {
11+ /**
12+ * The name of the factory's corresponding model.
13+ *
14+ * @var string
15+ */
16+ protected $ model = Category::class;
17+
18+ /**
19+ * Define the model's default state.
20+ *
21+ * @return array
22+ */
23+ public function definition ()
24+ {
25+ $ name = $ this ->faker ->jobTitle ;
26+ $ nameArr = explode (' ' , $ name );
27+
28+ $ name = trim ($ nameArr [0 ]);
29+
30+ return [
31+ 'name ' => $ name ,
32+ 'slug ' => Str::slug ($ name ),
33+ ];
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Database \Factories ;
4+
5+ use App \Models \Product ;
6+ use Illuminate \Database \Eloquent \Factories \Factory ;
7+
8+ class ProductFactory extends Factory
9+ {
10+ /**
11+ * The name of the factory's corresponding model.
12+ *
13+ * @var string
14+ */
15+ protected $ model = Product::class;
16+
17+ /**
18+ * Define the model's default state.
19+ *
20+ * @return array
21+ */
22+ public function definition ()
23+ {
24+ return [
25+ //
26+ ];
27+ }
28+ }
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ public function definition()
3030 'address ' => $ this ->faker ->address ,
3131 'city ' => $ this ->faker ->city ,
3232 'state ' => $ this ->faker ->state ,
33- 'zip_code ' => $ this ->faker ->postcode
33+ 'zipcode ' => $ this ->faker ->postcode
3434 ];
3535 }
3636}
You can’t perform that action at this time.
0 commit comments