public function detach() { $location = Location::find(Request::input('location')); $color = Color::find(Request::input('color')); foreach (Gauge::all() as $gauge) { $locationColorGauge = LocationColorGauge::where('location_id', '=', $location->id)->where('color_id', '=', $color->id)->where('gauge_id', '=', $gauge->id); if ($locationColorGauge->first()) { $locationColorGauge->first()->delete(); } } return "success"; }