public function actionCreate() { $model = new Town(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public static function createTown($name, $status, $userId, $departmentId) { $town = new Town(); $date = GeneralValues::getActualDate(); $town->name = $name; $town->status = $status; $town->created_at = $date; $town->updated_at = $date; $town->fk_user_who_create = $userId; $town->fk_town_department = $departmentId; $town->save(); return $town; }