app/Http/Controllers/LelangController.php
/**
     * Remove the specified resource from storage.
     *
     * @param  \App\Lelang  $lelang
     * @return \Illuminate\Http\Response
     */
Remove the specified resource from storage.
Remove the specified resource from storage .
public function destroy(Lelang $lelang)
    {
        if($lelang->status == 'ditutup'){
            return abort(403,'Forbidden access this');
        }
        DB::beginTransaction();
        $historyLelang = HistoryLelang::where(['id_lelang' => $lelang->id])->get();
        foreach($historyLelang as $row){
            $row->delete();
        }
        if($lelang->delete()){
            DB::commit();
            return redirect()->route('lelang.index')->with('success','Data berhasil dihapus');
        }
        DB::rollback();
        return redirect()->route('lelang.index')->with('error','Data gagal dihapus');
    }
public function destroy ( Lelang $ lelang ) { if ( $ lelang -> status == 'ditutup' ) { return abort ( 403 , 'Forbidden access this' ) ; } DB :: beginTransaction ( ) ; $ historyLelang = HistoryLelang :: where ( [ 'id_lelang' => $ lelang -> id ] ) -> get ( ) ; foreach ( $ historyLelang as $ row ) { $ row -> delete ( ) ; } if ( $ lelang -> delete ( ) ) { DB :: commit ( ) ; return redirect ( ) -> route ( 'lelang.index' ) -> with ( 'success' , 'Data berhasil dihapus' ) ; } DB :: rollback ( ) ; return redirect ( ) -> route ( 'lelang.index' ) -> with ( 'error' , 'Data gagal dihapus' ) ; }
Remove the specified resource from storage.
Remove the specified resource from storage .