mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 13:51:44 +00:00
feat: add tests and fix item level conditions for database storage
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user