public function run()
 {
     $this->truncateTable('contact_form');
     $faker = Faker::create();
     $contactIds = Contact::lists('id');
     $formIds = Form::lists('id');
     for ($i = 0; $i < 20; $i++) {
         DB::table('contact_form')->insert(['contact_id' => $faker->randomElement($contactIds), 'form_id' => $faker->randomElement($formIds), 'created_at' => $this->now, 'updated_at' => $this->now]);
     }
 }
Exemple #2
0
 /**
  * @param int $form_id
  * @param string $name
  * @param string $slug
  * @param array $relations
  * @return mixed
  */
 public function update($form_id, $name = null, $slug = null, array $relations = [])
 {
     $form = Form::findOrFail($form_id);
     $data = [];
     if (!is_null($name)) {
         $data['name'] = $name;
     }
     if (!is_null($slug)) {
         $data['slug'] = $slug;
     }
     $form->update($data);
     if (!empty($relations)) {
         $form = $this->handleRelations($form, $relations);
     }
     $form->save();
     return $form;
 }
 private function getUniqueIds($formIds, $propertyIds)
 {
     $ids = [];
     $unique = false;
     while (!$unique) {
         $formId = $this->faker->randomElement($formIds);
         $propertyId = $this->faker->randomElement($propertyIds);
         $form = Form::find($formId);
         $property = $form->properties->filter(function ($property) use($propertyId) {
             return $property->id === $propertyId;
         });
         if ($property->isEmpty()) {
             $unique = true;
             $ids = ['form_id' => $formId, 'property_id' => $propertyId];
         }
     }
     return $ids;
 }
 public function run()
 {
     $properties = $this->seedProperties();
     $form = Form::create(['name' => 'Perfect form', 'slug' => 'perfect-form']);
     $form->properties()->saveMany($properties);
 }
 public function run()
 {
     Form::create(['name' => 'My test form', 'slug' => 'my-test-form']);
     Factory::times(20)->create(Form::class);
 }
 public function run()
 {
     $this->truncateTable('forms');
     Form::create(['name' => 'My test form', 'slug' => 'my-test-form']);
     Factory::times(20)->create(Form::class);
 }
Exemple #7
0
 /** @test */
 public function it_updates_a_form()
 {
     $data = ['slug' => 'test-form-77', 'relations' => ['sync' => ['properties' => [4 => ['label' => 'abcd', 'default' => '1', 'required' => 0], 5 => ['label' => 'efgh', 'default' => '2', 'required' => 0], 6 => ['label' => 'ijkl', 'default' => '3', 'required' => 0]]], 'attach' => ['tags' => [10]]]];
     $response = $this->call('PUT', 'api/forms/1', [], [], [], $this->headers, json_encode($data));
     $content = json_decode($response->getContent());
     $updatedForm = \SevenShores\Kraken\Form::find(1);
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals($data['slug'], $content->slug);
     $this->assertEquals($data['slug'], $updatedForm->slug);
     $this->assertEquals(3, $updatedForm->properties->count());
     $this->assertEquals(10, $updatedForm->tags->last()->id);
 }