app/Http/Controllers/ProfileController.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(Request $request, $id)
    {
      $data = Profile::find($id);
      if ($request->file('image') == "") {
        $data->image = $data->image;
      }else{
        $path = 'images';
        $file = $request->file('image');
        $ext = $file->getClientOriginalExtension();
        $fileName = rand(1111,9999).".".$ext;
        $file->move($path,$fileName);
        $data->image = $fileName;
      }
      $data->nama_koperasi = $request->nama_koperasi;
      $data->alamat_koperasi = $request->alamat_koperasi;
      $data->telepon = $request->telepon;
      $data->keterangan = $request->keterangan;
      $data->kode_pos = $request->kode_pos;
      $data->update();
      return redirect()->route('profile.index');
    }
public function update ( Request $ request , $ id ) { $ data = Profile :: find ( $ id ) ; if ( $ request -> file ( 'image' ) == " " ) { $ data -> image = $ data -> image ; } else { $ path = 'images' ; $ file = $ request -> file ( 'image' ) ; $ ext = $ file -> getClientOriginalExtension ( ) ; $ fileName = rand ( 1111 , 9999 ) . " . " . $ ext ; $ file -> move ( $ path , $ fileName ) ; $ data -> image = $ fileName ; } $ data -> nama_koperasi = $ request -> nama_koperasi ; $ data -> alamat_koperasi = $ request -> alamat_koperasi ; $ data -> telepon = $ request -> telepon ; $ data -> keterangan = $ request -> keterangan ; $ data -> kode_pos = $ request -> kode_pos ; $ data -> update ( ) ; return redirect ( ) -> route ( 'profile.index' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .