feat: add tests and fix item level conditions for database storage

This commit is contained in:
Joel Male
2025-02-25 16:31:42 +10:00
parent 158cf38f14
commit 7adf5ecd1f
4 changed files with 116 additions and 9 deletions
+26
View File
@@ -70,6 +70,32 @@ public function putItems($value)
return $this->session->put($this->itemsKey, $value);
}
// convert any conditions to arrays
$value = $value->toArray();
foreach ($value as $key => $item) {
if ($item['conditions']) {
if (is_array($item['conditions'])) {
$value[$key]['conditions'] = collect($item['conditions'])->map(function ($condition) {
return $condition->toArray();
});
} else {
$value[$key]['conditions'] = $item['conditions']->toArray();
}
}
}
// if ($value['conditions']) {
// $value['conditions'] = $value['conditions']->map(function ($condition) {
// return $condition->toArray();
// });
// }
// dd($value);
// $value = $value->map(function ($item) {
// return $item->toArray();
// });
$this->session[$this->itemsKey] = $value;
$this->session->save();