public function run()
 {
     $this->truncateTable('contact_property');
     $faker = Faker::create();
     $contactIds = Contact::lists('id');
     $propertyIds = Property::lists('id');
     for ($i = 0; $i < 20; $i++) {
         DB::table('contact_property')->insert(['contact_id' => $faker->randomElement($contactIds), 'property_id' => $faker->randomElement($propertyIds), 'value' => $faker->word, 'created_at' => $this->now, 'updated_at' => $this->now]);
     }
 }
 public function run()
 {
     $this->truncateTable('form_property');
     $this->faker = Faker::create();
     $formIds = Form::lists('id');
     $propertyIds = Property::lists('id');
     for ($i = 0; $i < 40; $i++) {
         $ids = $this->getUniqueIds($formIds, $propertyIds);
         DB::table('form_property')->insert(['form_id' => $ids['form_id'], 'property_id' => $ids['property_id'], 'label' => $this->faker->sentence(2), 'default' => $this->faker->word, 'required' => $this->faker->boolean(25), 'created_at' => $this->now, 'updated_at' => $this->now]);
     }
 }
Esempio n. 3
0
 /**
  * Update the specified resource in storage.
  *
  * @param UpdatePropertyRequest $request
  * @param int $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function update(UpdatePropertyRequest $request, $id)
 {
     $property = Property::findOrFail($id);
     $data = ['name' => $request->json('name'), 'key' => $request->json('key'), 'label' => $request->json('label'), 'default' => $request->json('default'), 'required' => $request->json('required'), 'type_id' => $request->json('type_id')];
     foreach ($data as $name => $value) {
         if (!is_null($value)) {
             $property->{$name} = $value;
         }
     }
     $property->save();
     return $this->respondWithItem($property, new PropertyTransformer());
 }
 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;
 }
Esempio n. 5
0
<?php

use SevenShores\Kraken;
$propertyIds = Kraken\Property::lists('id');
$factory(Kraken\PropertyOption::class, ['value' => $faker->word, 'label' => $faker->word, 'property_id' => $faker->randomElement($propertyIds)]);
Esempio n. 6
0
 /** @test */
 public function it_updates_a_property()
 {
     $data = ['key' => 'test_property2', 'required' => false];
     $response = $this->call('PUT', 'api/properties/1', [], [], [], $this->headers, json_encode($data));
     $content = json_decode($response->getContent());
     $updatedProperty = \SevenShores\Kraken\Property::find(1);
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals($data['key'], $content->key);
     $this->assertEquals($data['required'], $updatedProperty->required);
 }