/** @test */
 public function it_updates_a_propertyOption()
 {
     $data = ['value' => 'test_property77', 'label' => 'Test property77'];
     $response = $this->call('PUT', 'api/property-options/1', [], [], [], $this->headers, json_encode($data));
     $content = json_decode($response->getContent());
     $updatedPropertyOption = \SevenShores\Kraken\PropertyOption::find(1);
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals($data['value'], $content->value);
     $this->assertEquals($data['value'], $updatedPropertyOption->value);
     $this->assertEquals($data['label'], $content->label);
     $this->assertEquals($data['label'], $updatedPropertyOption->label);
     //$this->assertEquals(4, $updatedPropertyOption->properties->where('id', 4)->first()->id);
     //$this->assertNull($updatedPropertyOption->properties->where('id', 1)->first());
 }
 /**
  * @param int $propertyOptionId
  * @param string $value
  * @param null $label
  * @param array $relations
  * @return mixed
  */
 public function update($propertyOptionId, $value = null, $label = null, array $relations = [])
 {
     $propertyOption = PropertyOption::findOrFail($propertyOptionId);
     $data = [];
     if (!is_null($value)) {
         $data['value'] = $value;
     }
     if (!is_null($label)) {
         $data['label'] = $label;
     }
     $propertyOption->update($data);
     if (!empty($relations)) {
         $propertyOption = $this->handleRelations($propertyOption, $relations);
     }
     $propertyOption->save();
     return $propertyOption;
 }
 private function seedProperties()
 {
     $this->truncateTable('properties');
     $properties = [];
     $properties['first_name'] = Property::create(['name' => 'First name', 'key' => 'first_name', 'label' => 'First name', 'required' => true, 'type_id' => $this->typeIds['Text']]);
     $properties['last_name'] = Property::create(['name' => 'Last name', 'key' => 'last_name', 'label' => 'Last name', 'required' => true, 'type_id' => $this->typeIds['Text']]);
     $properties['street'] = Property::create(['name' => 'Street', 'key' => 'street', 'label' => 'Street address', 'required' => false, 'type_id' => $this->typeIds['Text']]);
     $properties['province'] = Property::create(['name' => 'Province', 'key' => 'province', 'label' => 'Province', 'required' => false, 'type_id' => $this->typeIds['Text']]);
     $properties['country'] = Property::create(['name' => 'Country', 'key' => 'country', 'label' => 'Country', 'required' => false, 'type_id' => $this->typeIds['Text']]);
     $properties['postal_code'] = Property::create(['name' => 'Postal code', 'key' => 'postal_code', 'label' => 'Postal code', 'required' => false, 'type_id' => $this->typeIds['Text']]);
     $properties['phone_mobile'] = Property::create(['name' => 'Mobile phone', 'key' => 'phone_mobile', 'label' => 'Mobile phone', 'required' => false, 'type_id' => $this->typeIds['Text']]);
     $properties['phone_home'] = Property::create(['name' => 'Home phone', 'key' => 'phone_home', 'label' => 'Home phone', 'required' => false, 'type_id' => $this->typeIds['Text']]);
     $properties['age'] = Property::create(['name' => 'Age', 'key' => 'age', 'label' => 'Age', 'required' => false, 'type_id' => $this->typeIds['Text']]);
     $properties['gender'] = Property::create(['name' => 'Gender', 'key' => 'gender', 'label' => 'Gender', 'required' => false, 'type_id' => $this->typeIds['Select']]);
     $gender_male = PropertyOption::create(['value' => 'male', 'label' => 'Male', 'property_id' => $properties['gender']->id]);
     $gender_female = PropertyOption::create(['value' => 'female', 'label' => 'Female', 'property_id' => $properties['gender']->id]);
     return $properties;
 }