app/Http/Controllers/soporte/ClienteController.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(StoreCliente $request, Cliente $cliente)
    {
        try {
            DB::beginTransaction();
            $cliente->update($request->all());
            if ($request->ffoto) {
                $cade = str_replace('storage', 'public', $cliente->ffoto);
                Storage::delete($cade);
                $image = $request->file('ffoto')->store('public/image');
                $url = Storage::url($image);
                $cliente->ffoto = $url;
            }
            if ($request->fcedula1) {
                $cade = str_replace('storage', 'public', $cliente->fcedula1);
                Storage::delete($cade);
                $image = $request->file('fcedula1')->store('public/cedula1');
                $url = Storage::url($image);
                $cliente->fcedula1 = $url;
            }
            if ($request->fcedula2) {
                $cade = str_replace('storage', 'public', $cliente->fcedula2);
                Storage::delete($cade);
                $image = $request->file('fcedula2')->store('public/cedula2');
                $url = Storage::url($image);
                $cliente->fcedula2 = $url;
            }
            $cliente->save();
            DB::commit();
            return redirect()->route('clientes.index');
        } catch (\Exception $exception) {
            DB::rollback();
            return  redirect()->back()->with('error', "Error" . $exception->getMessage());
        }
    }
public function update ( StoreCliente $ request , Cliente $ cliente ) { try { DB :: beginTransaction ( ) ; $ cliente -> update ( $ request -> all ( ) ) ; if ( $ request -> ffoto ) { $ cade = str_replace ( 'storage' , 'public' , $ cliente -> ffoto ) ; Storage :: delete ( $ cade ) ; $ image = $ request -> file ( 'ffoto' ) -> store ( 'public/image' ) ; $ url = Storage :: url ( $ image ) ; $ cliente -> ffoto = $ url ; } if ( $ request -> fcedula1 ) { $ cade = str_replace ( 'storage' , 'public' , $ cliente -> fcedula1 ) ; Storage :: delete ( $ cade ) ; $ image = $ request -> file ( 'fcedula1' ) -> store ( 'public/cedula1' ) ; $ url = Storage :: url ( $ image ) ; $ cliente -> fcedula1 = $ url ; } if ( $ request -> fcedula2 ) { $ cade = str_replace ( 'storage' , 'public' , $ cliente -> fcedula2 ) ; Storage :: delete ( $ cade ) ; $ image = $ request -> file ( 'fcedula2' ) -> store ( 'public/cedula2' ) ; $ url = Storage :: url ( $ image ) ; $ cliente -> fcedula2 = $ url ; } $ cliente -> save ( ) ; DB :: commit ( ) ; return redirect ( ) -> route ( 'clientes.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 .
//Código de validación de datos // Storage::deleteDirectory($cliente->ffoto); //$cedula1=$request->file('fcedula1')->store('public/cedula1'); //$urll=Storage::url($cedula1); //$cedula2=$request->file('fcedula2')->store('public/cedula2'); //$urlll=Storage::url($cedula2); // $cliente->fcedula1=$urll; //$cliente->fcedula2=$urlll;