This works, I guess...
$key = 'UserChoices';
Session::put($key, [10,22,31]); /* Lets start with some data */
$choices = Session::get($key); /* Get all ids. returns (array) */
$idExists = in_array($choices, $id); /* Id exists ? returns (bool) */
$choices[] = $idToAdd; /* Add a single id */
$choices = array_merge($choices, $arrayOfIds); /* Ad an array of ids */
unset( $choices[$idToRemove] ); /* Remove an id */
Session::put($key, $choices); /* Just save it ! */
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community