public function actionAdd()
 {
     $data = Yii::$app->request->post();
     $y_id = $data['id'];
     //Поиск дубля
     $duble = Video::find()->where(['youtube_id' => $y_id])->one();
     if (!empty($duble)) {
         Yii::$app->session->setFlash('error', "Такое видео уже есть на сайте!");
         return $this->redirect('/video/index');
     }
     //vd($data);
     $_model = new Video();
     $_model->youtube_id = $data['id'];
     $_model->title = $data['title'];
     $_model->descr = $data['descr'];
     $_model->categoria = $data['categoria'];
     $_model->author_id = $data['author_id'];
     //$_model->validate();
     //vd($_model->getErrors());
     if ($_model->save() && $_model->validate()) {
         Yii::$app->session->setFlash('success', "Видео успешно добавленно!");
     } else {
         Yii::$app->session->setFlash('error', "Error! Ошибка");
     }
     return $this->redirect('/video/index');
 }
 public function actionInterview()
 {
     $userdetails = \Yii::$app->user->identity;
     $model = InterviewVideo::find()->where(['user_id' => $userdetails->id])->one();
     //echo "<pre>";print_r($model->video);die;
     if (empty($model)) {
         $model = new InterviewVideo();
     }
     $video = new Video();
     $user = Userform::find()->where(['id' => $userdetails->id])->one();
     if (empty($user)) {
         $user = new Userform();
     }
     $userprofile = UserProfile::find()->where(['user_id' => $userdetails->id])->one();
     if (empty($userprofile)) {
         $userprofile = new UserProfile();
     }
     if (isset($_POST['Video'])) {
         $video->attributes = $_POST['Video'];
         $video->media_module_id = 5;
         // id 5 is interview video type in tlb_media_module table
         $model->user_id = $userdetails->id;
         if ($video->validate()) {
             $video->save();
             $model->video_id = $video->id;
             $model->save();
         }
     }
     return $this->render('interview', ['model' => $model, 'user' => $user, 'video' => $video, 'userprofile' => $userprofile]);
 }