public function storeProductionUnits() { //save the data //TODO : Validation - Redudundant unit types. //equivalent in grams $equivalents = Input::get('prod_units'); //unit ids $unit_id = Input::get('unit_id'); //ingredient id $ing_id = Input::get('ing_id'); $prod_unit = new ProductionUnit(); //get the list of the production units on the ingredient $ing_units = $prod_unit->getIngredientUnits($ing_id); // return $ing_units; if (in_array($unit_id, $ing_units)) { return Response::json(['response' => 300, 'msg' => 'Unit already exists.']); } $units = $prod_unit->storeProductionUnits($ing_id, $equivalents, $unit_id); return Response::json(['response' => 200]); }