From c6c8d18ae2597035fb4610176f9ba02dc02ba6d7 Mon Sep 17 00:00:00 2001 From: b1ek Date: Thu, 28 Nov 2024 02:39:29 +1000 Subject: [PATCH] add seeder migration --- migrations/m0000001_seed.php | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 migrations/m0000001_seed.php diff --git a/migrations/m0000001_seed.php b/migrations/m0000001_seed.php new file mode 100644 index 0000000..6b168be --- /dev/null +++ b/migrations/m0000001_seed.php @@ -0,0 +1,57 @@ +name = $gen->firstName(); + $user->login = 'user_' + $i; + $user->phone = $gen->phoneNumber(); + $user->passHash = Yii::$app->getSecurity()->generatePasswordHash('pass_' + $i); + $user->save(); + + $material = new Material(); + $material->title = $gen->words(10, true); + $material->content = $gen->paragraph(); + $material->blog_id = 0; + $material->save(); + + $company = new Company(); + $company->title = $gen->words(2, true); + $company->website = "https://" . $gen->word() . '.com'; + $company->address = $gen->address(); + $company->save(); + + $blog = new Blog(); + $blog->save(); + + $subscription = new Subscription(); + $subscription->user_id = $user->id; + $subscription->blog_id = $blog->id; + $subscription->save(); + + $comment = new Comment(); + $comment->material_id = $material->id; + $comment->user_id = $user->id; + $comment->content = $gen->paragraph(); + $comment->save(); + } + } +} \ No newline at end of file