/** * @test */ public function it_instantiates_as_eloquent_by_default() { $emptyModel = new Attribute(); $arrayModel = new Attribute([]); $this->assertEquals([], $emptyModel->getAttributes()); $this->assertEquals([], $arrayModel->getAttributes()); }
/** * Update existing attribute. * * @param \Sofa\Eloquence\Metable\Attribute|string $key * @param mixed $value * @return $this */ protected function update($key, $value = null) { if ($key instanceof Attribute) { $value = $key->getValue(); $key = $key->getMetaKey(); } $this->get($key)->setValue($value); return $this; }
/** * Set attribute. * * @param \Sofa\Eloquence\Metable\Attribute $attribute */ protected function setInstance(Attribute $attribute) { if ($this->has($attribute->getMetaKey())) { $this->update($attribute); } else { $this->items[$attribute->getMetaKey()] = $attribute; } return $this; }