Support the ongoing development of Laravel.io →
Requests Session
Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Braunson braunson Joined 20 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.