app/Http/Controllers/PeliculaController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(PeliculaRequest $request, $id)
    {
        try{
            $this->authorize('update', Pelicula::findOrFail($id));
            $pelicula=Pelicula::updateOrCreate(['idPelicula'=>$id],$request->except('idGenero','idActor'));
            $pelicula->generos()->sync($request->idGenero);
            $pelicula->actores()->sync($request->idActor);
            return redirect('peliculas')->with('success','Pelicula actualizada');
        }catch(Exception $e){
            return back()->withErrors(['exception'=>$e->getMessage()])->withInput();
        }        
    }
public function update ( PeliculaRequest $ request , $ id ) { try { $ this -> authorize ( 'update' , Pelicula :: findOrFail ( $ id ) ) ; $ pelicula = Pelicula :: updateOrCreate ( [ 'idPelicula' => $ id ] , $ request -> except ( 'idGenero' , 'idActor' ) ) ; $ pelicula -> generos ( ) -> sync ( $ request -> idGenero ) ; $ pelicula -> actores ( ) -> sync ( $ request -> idActor ) ; return redirect ( 'peliculas' ) -> with ( 'success' , 'Pelicula actualizada' ) ; } catch ( Exception $ e ) { return back ( ) -> withErrors ( [ 'exception' => $ e -> getMessage ( ) ] ) -> withInput ( ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .