2
I’m using Yii2 and doing a website project where one of the features is to list the movies linked to a specific user. I already have a method to associate movies to accounts and one that makes the tables Inner Join.
(Action code):
public function actionAssociarFilme($idFilme){
$model = new FilmeHasCompra();
$model->Filme_idFilme = $idFilme;
$model->Usuario_idUsuario = Yii::$app->user->identity->idUsuario;
$model->save();
return $this->goBack();
}
public function actionListarFilme(){
$resultado = Filme::find()
->innerJoin('filme_has_compra', 'filme_has_compra.Filme_idFilme=Filme.idFilme')
->where('filme_has_compra.Usuario_idUsuario=:idusuario',['idusuario'=>Yii::$app->user->identity->idUsuario]) ->all();
return $this->render('tables',['resultado'=>$resultado]);
}
}
The question is how to call this action Listarfilme in the view, because when I try to call it appears a Unknown error method
Instead of using code image, copy and paste. So it will be easier for someone to answer the question.
– Andrei Coelho
Your doubt is how to call the action because the error "Unknown method" is occurring, but you have not made it clear where this action is calling. Could you put the stretch with the line that this error occurs? It will be easier so to find a solution.
– Lucas Emanuel