/** * Creates a new Pet model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Pet(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model]); } }
/** * Store pet into database * * @param array $input * @return boolean */ public function createPet($input) { $result = Pet::validate($input); if (!is_bool($result)) { return $this->setMessage($result); } $pet = new Pet(); $pet->pet_name = $input['name']; $pet->description = $input['description']; $pet->save(); return $result; }