Conditions | 2 |
Paths | 2 |
Total Lines | 46 |
Code Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
7 | public function run() |
||
8 | { |
||
9 | $faker = Faker\Factory::create(); |
||
10 | $category = $this->table('category'); |
||
11 | $count = rand(5, 10); |
||
12 | |||
13 | for ($i = 0; $i < $count; $i++) { |
||
14 | $id = $faker->uuid; |
||
15 | $mysqlUuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
||
16 | $categoryName = $faker->name; |
||
17 | |||
18 | $data = [ |
||
19 | 'category_uuid' => $mysqlUuid, |
||
20 | 'category_id' => $id, |
||
21 | 'name' => $categoryName, |
||
22 | 'slug' => preg_replace('/[^a-z0-9]/i', '-', strtolower($categoryName)), |
||
23 | 'type' => \Article\Entity\ArticleType::POST, |
||
24 | 'is_in_homepage' => rand(0, 1), |
||
25 | 'is_in_category_list' => rand(0, 1), |
||
26 | ]; |
||
27 | |||
28 | $category->insert($data)->save(); |
||
29 | } |
||
30 | |||
31 | // Insert special category - videos |
||
32 | $id = $faker->uuid; |
||
33 | $mysqlUuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
||
34 | $category->insert([ |
||
35 | 'category_uuid' => $mysqlUuid, |
||
36 | 'category_id' => $id, |
||
37 | 'name' => 'Videos', |
||
38 | 'slug' => 'videos', |
||
39 | 'type' => \Article\Entity\ArticleType::VIDEO, |
||
40 | ])->save(); |
||
41 | |||
42 | // Insert special category - events |
||
43 | $id = $faker->uuid; |
||
44 | $mysqlUuid = (new MysqlUuid\Uuid($id))->toFormat(new MysqlUuid\Formats\Binary()); |
||
45 | $category->insert([ |
||
46 | 'category_uuid' => $mysqlUuid, |
||
47 | 'category_id' => $id, |
||
48 | 'name' => 'Events', |
||
49 | 'slug' => 'events', |
||
50 | 'type' => \Article\Entity\ArticleType::EVENT, |
||
51 | ])->save(); |
||
52 | } |
||
53 | } |
||
54 |