Was hoping there was a more elegant Laravel related way of doing this as unset() is my last resort..
The current solution (that works) is..
$sessionKey = Config::get('session.temp_key');
$ingredients = Session::get($sessionKey);
foreach ( $ingredients as $key => $value)
{
if (isset($value['food_id']) && $ingredient_id == $value['food_id'])
unset($ingredients[$key]);
}
Session::set($sessionKey, $ingredients);
Next issue is adding to an ingredient array when a (serving) and (serving size) is added/changed.. thoughts?
Now for each ingredient there is a serving array with many servings, if the user selects a serving type and types in a serving size then I need to figure out how to inject another array ['selected' = [ 'serving_size' => 1, 'serving' => 'cup']] and be able to easily change that if the user changes the serving/size for any ingredient.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community