Commit 78f13726 authored by Thorsten Buss's avatar Thorsten Buss

add __isset() to the __get() functions +FIX if condition key on item does not exists

parent cb952a9f
......@@ -15,4 +15,9 @@ class Attribute extends Collection {
if ($this->has($name)) return $this->get($name);
return null;
}
public function __isset($name) {
return $this->has($name);
}
}
\ No newline at end of file
......@@ -224,4 +224,7 @@ class Condition extends Collection {
return null;
}
public function __isset($name) {
return $this->has($name);
}
}
\ No newline at end of file
......@@ -28,10 +28,10 @@ class Item extends Collection {
*/
public function __construct($attributes) {
// make conditions as array and set target to item if not set
if (isset($attributes['conditions']) && !empty($attributes['conditions']))
if (isset($attributes['conditions']) && !empty($attributes['conditions'])) {
if (!is_array($attributes['conditions']))
$attributes['conditions'] = [$attributes['conditions']];
collect($attributes['conditions'])->transform(function($condition) {
collect($attributes['conditions'])->transform(function ($condition) {
if ($condition instanceof Condition) {
if ($condition->getTarget() == 'cart')
return false;
......@@ -39,6 +39,7 @@ class Item extends Collection {
} else
$condition['target'] = 'item';
});
}
parent::__construct($attributes);
}
......@@ -62,6 +63,10 @@ class Item extends Collection {
return null;
}
public function __isset($name) {
return $this->has($name);
}
/**
* check if item has conditions
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment