/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $productType = ProductType::find($id); $products = DB::table('products')->select('id')->where('product_type_id', '=', $productType->id)->get(); foreach ($products as $product) { Product::destroy($product->id); } ProductType::destroy($id); Session::flash('message', 'Tipo de producto Eliminado Correctamente'); return Redirect::to('/productType'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $provider = Provider::find($id); $products = DB::table('products')->select('id')->where('provider_id', '=', $provider->id)->get(); foreach ($products as $product) { Product::destroy($product->id); } Provider::destroy($id); Session::flash('message', 'Proveedor eliminado correctamente'); return Redirect::to('/provider'); }