app/Http/Controllers/GaleriController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\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)
    {
        $request->validate([
            'nama' => 'required',
            'keterangan' => 'required',
            'jenis_file' => 'required',
            'file' => 'image|video|mimes:jpeg,png,jpg,gif,svg,mp4,mkv,avi,mov,mpeg|max:4096',
        ]);
        $input = $request->all();
        if ($file = $request->file('file')) {
            $destinationPath = 'file/galeri/';
            $profileFile = date('YmdHis') . "." . $file->getClientOriginalExtension();
            $file->move($destinationPath, $profileFile);
            $input['file'] = "$profileFile";
        }else{
            unset($input['file']);
        }
        $galeri->update($input);
        return redirect()->route('galeris.index')
                        ->with('success','Galeri Berhasil Diupdate !');
    }
public function update ( Request $ request , Galeri $ galeri ) { $ request -> validate ( [ 'nama' => 'required' , 'keterangan' => 'required' , 'jenis_file' => 'required' , 'file' => 'image|video|mimes:jpeg,png,jpg,gif,svg,mp4,mkv,avi,mov,mpeg|max:4096' , ] ) ; $ input = $ request -> all ( ) ; if ( $ file = $ request -> file ( 'file' ) ) { $ destinationPath = 'file/galeri/' ; $ profileFile = date ( 'YmdHis' ) . " . " . $ file -> getClientOriginalExtension ( ) ; $ file -> move ( $ destinationPath , $ profileFile ) ; $ input [ 'file' ] = " $ profileFile " ; } else { unset ( $ input [ 'file' ] ) ; } $ galeri -> update ( $ input ) ; return redirect ( ) -> route ( 'galeris.index' ) -> with ( 'success' , 'Galeri Berhasil Diupdate !' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .