コード例 #1
0
 public function run()
 {
     $this->truncateTable('taggables');
     $faker = Faker::create();
     $tagIds = Tag::lists('id');
     $contactIds = Contact::lists('id');
     for ($i = 0; $i < 40; $i++) {
         DB::table('taggables')->insert(['tag_id' => $faker->randomElement($tagIds), 'taggable_id' => $faker->randomElement($contactIds), 'taggable_type' => Contact::class]);
     }
 }
コード例 #2
0
 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]);
     }
 }
コード例 #3
0
 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]);
     }
 }
コード例 #4
0
ファイル: ContactManager.php プロジェクト: creativify/kraken
 /**
  * @param int $contact_id
  * @param null $email
  * @param array $relations
  * @return mixed
  */
 public function update($contact_id, $email = null, array $relations = [])
 {
     $contact = Contact::findOrFail($contact_id);
     if (!is_null($email)) {
         $contact->update(['email' => $email]);
     }
     if (!empty($relations)) {
         $contact = $this->handleRelations($contact, $relations);
     }
     $contact->save();
     return $contact;
 }
コード例 #5
0
 public function run()
 {
     $this->truncateTable('contacts');
     Contact::create(['email' => '*****@*****.**']);
     Factory::times(40)->create(Contact::class);
 }
コード例 #6
0
ファイル: ContactsTest.php プロジェクト: creativify/kraken
 /** @test */
 public function it_updates_a_contact()
 {
     $data = ['email' => '*****@*****.**', 'relations' => ['sync' => ['tags' => [4, 5, 6]], 'attach' => ['forms' => [2]]]];
     $contactToUpdate = \SevenShores\Kraken\Contact::find(1);
     $contactToUpdate->detach('forms', [2]);
     $response = $this->call('PUT', 'api/contacts/1', [], [], [], $this->headers, json_encode($data));
     $content = json_decode($response->getContent());
     $updatedContact = \SevenShores\Kraken\Contact::find(1);
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals($data['email'], $content->email);
     $this->assertEquals($data['email'], $updatedContact->email);
     $this->assertEquals(3, $updatedContact->tags->count());
     $this->assertEquals(2, $updatedContact->forms->where('id', 2)->first()->id);
 }