Esempio n. 1
0
 /**
  * Creates a new Videos model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Videos();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Esempio n. 2
0
 /**
  * Creates a new Videos model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Videos();
     //var_dump(strpos('https://www.youtube.com/watch?v=gDAY1Tfc-zY', 'youtube'));
     //https://www.youtube.com/watch?v=gDAY1Tfc-zY
     //http://img.youtube.com/vi/gDAY1Tfc-zY/mqdefault.jpg
     if ($model->load(Yii::$app->request->post())) {
         $model->user_id = Yii::$app->user->id;
         $model->img_link = $model->getVideoImage($model->link);
         $model->link = $model->getEmbedLink($model->link);
         $videoCategories = new VideosCategories();
         if ($model->save()) {
             if ($videoCategories->saveVideosCategories($model->id, Yii::$app->request->post('categories'))) {
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         } else {
             return $this->render('create', ['model' => $model, 'videosCategories' => VideosCategories::find()->all()]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'videosCategories' => VideosCategories::find()->all()]);
     }
 }