コード例 #1
0
 /**
  * Execute the command.
  *
  * @param AttributeRepository $attributes
  * @param AttributeValueRepository $values
  * @return Attribute
  */
 public function handle(AttributeRepository $attributes, AttributeValueRepository $values)
 {
     $attribute = $attributes->findById($this->id)->fill($this->getProperties());
     $attributes->save($attribute);
     if ($this->add_value) {
         $value = AttributeValue::register($attribute->id, $this->add_value);
         $values->save($value);
     }
     return $attribute;
 }
コード例 #2
0
 /**
  * Find an attribute by id.
  *
  * @param int $id
  * @return AttributeValue
  * @throws ModelNotFoundException
  */
 public function findById($id)
 {
     return AttributeValue::findOrFail($id);
 }
コード例 #3
0
 function it_can_be_registered()
 {
     $value = AttributeValue::register(1, 'Blue');
     \PHPUnit_Framework_Assert::assertEquals(1, $value->attribute_id);
     \PHPUnit_Framework_Assert::assertEquals('Blue', $value->value);
 }