app/Http/Controllers/GalleriController.php
/**
     * Remove the specified resource from storage.
     *
     * @param  \App\Galleri  $galleri
     * @return \Illuminate\Http\Response
     */
Remove the specified resource from storage.
Remove the specified resource from storage .
public function destroy($id)
    {
        $galleri = Galleri::findOrFail($id);
        if($galleri->photos){
            $old_foto = $galleri->photos;
            $filepath = public_path() .DIRECTORY_SEPARATOR. 'img'.DIRECTORY_SEPARATOR. $galleri->photos;
            try{
                File::delete($filepath);
            }catch (FileNotFoundException $e){
            }
            $galleri->delete();
            return redirect()->route('galleri.index');
        }
    }
public function destroy ( $ id ) { $ galleri = Galleri :: findOrFail ( $ id ) ; if ( $ galleri -> photos ) { $ old_foto = $ galleri -> photos ; $ filepath = public_path ( ) . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . $ galleri -> photos ; try { File :: delete ( $ filepath ) ; } catch ( FileNotFoundException $ e ) { } $ galleri -> delete ( ) ; return redirect ( ) -> route ( 'galleri.index' ) ; } }
Remove the specified resource from storage.
Remove the specified resource from storage .