app/Http/Controllers/recursoshumanos/rrhempleadocontroller.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(empleado $request)
    {
        try {
            DB::beginTransaction();
            $rrhempleado = Rrhempleado::Create($request->all());
            if ($request->ffoto) {
                $image = $request->file('ffoto')->store('public/empleado');
                $url = Storage::url($image);
                $rrhempleado->ffoto = $url;
            }
            $rrhempleado->save();
            DB::commit();
            return redirect()->route('rhempleados.index');
        } catch (\Exception $exception) {
            DB::rollback();
            return  redirect()->back()->with('error', "Error" . $exception->getMessage());
        }
    }
public function store ( empleado $ request ) { try { DB :: beginTransaction ( ) ; $ rrhempleado = Rrhempleado :: Create ( $ request -> all ( ) ) ; if ( $ request -> ffoto ) { $ image = $ request -> file ( 'ffoto' ) -> store ( 'public/empleado' ) ; $ url = Storage :: url ( $ image ) ; $ rrhempleado -> ffoto = $ url ; } $ rrhempleado -> save ( ) ; DB :: commit ( ) ; return redirect ( ) -> route ( 'rhempleados.index' ) ; } catch ( \ Exception $ exception ) { DB :: rollback ( ) ; return redirect ( ) -> back ( ) -> with ( 'error' , " Error " . $ exception -> getMessage ( ) ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .
//