/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Directorpelicula::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'directorid' => $this->directorid, 'peliculaid' => $this->peliculaid]);
     return $dataProvider;
 }
 /**
  * Creates a new Pelicula model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Pelicula();
     $modelActor = [new Actorpelicula()];
     $modelDirector = [new Directorpelicula()];
     $modeltipoPelicula = [new Tipopeliculapelicula()];
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $modelActor = Model::createMultiple(Actorpelicula::classname());
         Model::loadMultiple($modelActor, Yii::$app->request->post());
         $modelDirector = Model::createMultiple(Directorpelicula::classname());
         Model::loadMultiple($modelDirector, Yii::$app->request->post());
         $modeltipoPelicula = Model::createMultiple(Tipopeliculapelicula::classname());
         Model::loadMultiple($modeltipoPelicula, Yii::$app->request->post());
         $valid = $model->validate();
         $valid = Model::validateMultiple($modelActor) && $valid;
         $valid = Model::validateMultiple($modelDirector) && $valid;
         $valid = Model::validateMultiple($modeltipoPelicula) && $valid;
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Finds the Directorpelicula model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Directorpelicula the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Directorpelicula::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDirectorpeliculas()
 {
     return $this->hasMany(Directorpelicula::className(), ['peliculaid' => 'id']);
 }