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