/** * Creates a new CompanyPhone model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new CompanyPhone(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
private function providePhones($count = 150) { print_r("Provide phones. Count: " . $count . "..."); $this->faker->unique(true); $companies = Company::find()->asArray()->all(); $company_ids = ArrayHelper::getColumn($companies, 'id'); $company_ids_length = count($company_ids) - 1; for ($i = 0; $i < $count; $i++) { $company_phone = new CompanyPhone(); $company_phone->phone = $this->faker->unique()->phoneNumber; $company_phone->company_id = $company_ids[mt_rand(1, $company_ids_length)]; $company_phone->save(); } print_r("DONE" . PHP_EOL); }