Exemplo n.º 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]);
     }
 }
Exemplo n.º 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param UpdateTagRequest $request
  * @param int $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function update(UpdateTagRequest $request, $id)
 {
     $tag = Tag::findOrFail($id);
     $data = ['name' => $request->json('name'), 'slug' => $request->json('slug'), 'description' => $request->json('description')];
     foreach ($data as $name => $value) {
         if (!is_null($value)) {
             $tag->{$name} = $value;
         }
     }
     $tag->save();
     return $this->respondWithItem($tag, new TagTransformer());
 }
Exemplo n.º 3
0
 public function run()
 {
     $this->truncateTable('tags');
     Tag::create(['name' => 'Sports', 'slug' => 'sports', 'description' => 'Related to sports or athletics.']);
     Factory::times(20)->create(Tag::class);
 }
Exemplo n.º 4
0
 /** @test */
 public function it_updates_a_tag()
 {
     $data = ['name' => 'Test tag 2'];
     $response = $this->call('PUT', 'api/tags/1', [], [], [], $this->headers, json_encode($data));
     $content = json_decode($response->getContent());
     $updatedTag = \SevenShores\Kraken\Tag::find(1);
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals($data['name'], $content->name);
     $this->assertEquals($data['name'], $updatedTag->name);
 }