app/Http/Controllers/MasyarakatController.php
/**
     * Remove the specified resource from storage.
     *
     * @param  \App\Masyarakat  $masyarakat
     * @return \Illuminate\Http\Response
     */
Remove the specified resource from storage.
Remove the specified resource from storage .
public function destroy(Masyarakat $masyarakat)
    {
        if(File::exists('images/'.$masyarakat->photo)){
            unlink('images/'.$masyarakat->photo);
        }
        if($masyarakat->delete()){
            return redirect()->route('masyarakat.index')->with(
                "success","Data berhasil disimpan");
        }else{
            return redirect()->route('masyarakat.index')->with(
                "error","Data gagal disimpan");
        }
    }
public function destroy ( Masyarakat $ masyarakat ) { if ( File :: exists ( 'images/' . $ masyarakat -> photo ) ) { unlink ( 'images/' . $ masyarakat -> photo ) ; } if ( $ masyarakat -> delete ( ) ) { return redirect ( ) -> route ( 'masyarakat.index' ) -> with ( " success " , " Data berhasil disimpan " ) ; } else { return redirect ( ) -> route ( 'masyarakat.index' ) -> with ( " error " , " Data gagal disimpan " ) ; } }
Remove the specified resource from storage.
Remove the specified resource from storage .