/** * Deletes an existing Route model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param string $id * @return mixed */ public function actionGenerate() { $routes = $this->searchRoute('all'); foreach ($routes as $route => $status) { if (!Route::findOne($route)) { $model = new Route(); $model->name = $route; $pos = strrpos($route, '/'); $model->type = substr($route, 1, $pos - 1); $model->alias = substr($route, $pos + 1, 64); $model->save(); } } Yii::$app->session->setFlash('success', 'Route success generate'); return $this->redirect(['index']); }