app/Http/Controllers/GaleriController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Galeri  $galeri
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Galeri $galeri){
      $file = $request->file('sampul');
      if (is_null($file)) {
        $nama_file = $galeri -> sampul;
      } else {
        $tujuan_upload = 'img/galeri';
        $nama_file = time()."_".$file->getClientOriginalName();
        $file->move($tujuan_upload,$nama_file);
      }
      Galeri::where('id', $galeri->id)
          ->update(
            [
              'judul' => $request -> judul,
              'sampul' => $nama_file,
              'linkVideo' => $request -> linkVideo,
              'caption' => $request -> caption,
            ]
          );
      return redirect()->route('mine.galeri')->with('successGaleri', 'Galeri Berhasil Diubah');
    }
public function update ( Request $ request , Galeri $ galeri ) { $ file = $ request -> file ( 'sampul' ) ; if ( is_null ( $ file ) ) { $ nama_file = $ galeri -> sampul ; } else { $ tujuan_upload = 'img/galeri' ; $ nama_file = time ( ) . " _ " . $ file -> getClientOriginalName ( ) ; $ file -> move ( $ tujuan_upload , $ nama_file ) ; } Galeri :: where ( 'id' , $ galeri -> id ) -> update ( [ 'judul' => $ request -> judul , 'sampul' => $ nama_file , 'linkVideo' => $ request -> linkVideo , 'caption' => $ request -> caption , ] ) ; return redirect ( ) -> route ( 'mine.galeri' ) -> with ( 'successGaleri' , 'Galeri Berhasil Diubah' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .