/** * Creates a new Rubric model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Rubric(); 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 createRubrics($count = 50) { print_r("Create rubrics. Count: " . $count . "..."); $this->faker->unique(true); for ($i = 1; $i <= $count; $i++) { $rubric = new Rubric(); $rubric->title = ucfirst($this->faker->word); if ($i === 1) { $parent_id = NULL; } else { do { $parent_id = $this->faker->optional(0.7)->numberBetween(1, $i); } while ($parent_id === $i); } $rubric->parent_id = $parent_id; $rubric->save(); } print_r("DONE" . PHP_EOL); }