/** * Finds the EducationLevel model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return EducationLevel the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = SocialMediaPlatform::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates a new SocialmediaPlatform model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new SocialMediaPlatform(); if ($model->load(Yii::$app->request->post())) { /*print_r($model); die();*/ $model->sp_name = $model->sp_name; $model->sp_description = $model->sp_description; $model->save(); return $this->redirect(['view', 'id' => $model->sp_id]); } else { return $this->render('create', ['model' => $model]); } /* if ($model->load(Yii::$app->request->post())) { $model->imageFile = UploadedFile::getInstance($model, 'imageFile'); $save_file = ''; if($model->imageFile){ $imagepath = 'uploads/socialmedia_image/'; // Create folder under web/uploads/logo $model->sp_logo = $imagepath .rand(10,100).'-'.$model->imageFile->name; $save_file = 1; //print_r($model->sp_logo); die(); } if ($model->save()) { if($save_file){ $model->imageFile->saveAs($model->sp_logo); } return $this->redirect(['view', 'id' => $model->sp_id]); } } else { return $this->render('create', [ 'model' => $model, ]); }*/ }