app/Http/Controllers/recursoshumanos/rrhempleadocontroller.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(empleado $request, $id)
    {
        try {
            DB::beginTransaction();
            $rrhempleado = Rrhempleado::find($id);
                Storage::deleteDirectory($rrhempleado->ffoto);
            $rrhempleado->update($request->all());
            if ($request->ffoto) {
                $cade = str_replace('storage', 'public', $rrhempleado->ffoto);
                Storage::delete($cade);
                $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 update ( empleado $ request , $ id ) { try { DB :: beginTransaction ( ) ; $ rrhempleado = Rrhempleado :: find ( $ id ) ; Storage :: deleteDirectory ( $ rrhempleado -> ffoto ) ; $ rrhempleado -> update ( $ request -> all ( ) ) ; if ( $ request -> ffoto ) { $ cade = str_replace ( 'storage' , 'public' , $ rrhempleado -> ffoto ) ; Storage :: delete ( $ cade ) ; $ 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 ( ) ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .