app/Http/Controllers/ActorController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(ActorRequest $request)
    {
        try{
            $actor=Actor::create($request->all());           
            if ($request->hasFile('imagen')) {
                $actor->imagen = $request->file('imagen')->store('public/actores');
                $actor->save();
            }
            return redirect('actores')->with('success','Actor registrado');
        }catch(Exception $e){
            return back()->withErrors(['exception'=>$e->getMessage()])->withInput();
        }
    }
public function store ( ActorRequest $ request ) { try { $ actor = Actor :: create ( $ request -> all ( ) ) ; if ( $ request -> hasFile ( 'imagen' ) ) { $ actor -> imagen = $ request -> file ( 'imagen' ) -> store ( 'public/actores' ) ; $ actor -> save ( ) ; } return redirect ( 'actores' ) -> with ( 'success' , 'Actor registrado' ) ; } catch ( Exception $ e ) { return back ( ) -> withErrors ( [ 'exception' => $ e -> getMessage ( ) ] ) -> withInput ( ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .
//ask