예제 #1
0
 public function testToggleGoal()
 {
     $skill = \Tsny\Models\Skill::find(1);
     $this->post('api/skill/1/toggle');
     $this->seeInDatabase('skills', ['id' => 1, 'current' => !$skill->current]);
     $this->post('api/skill/1/toggle');
     $this->seeInDatabase('skills', ['id' => 1, 'current' => $skill->current]);
 }
예제 #2
0
 public function toggle($skill_id)
 {
     $skill = Skill::where('id', $skill_id)->select('id', 'current')->first();
     $skill->current = !$skill->current;
     if ($skill->save()) {
         return Response::json($skill);
     }
     return Response::json(['message' => 'There was a problem updating the skill.'], 400);
 }
예제 #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Skill::truncate();
     $faker = Faker\Factory::create();
     Skill::create(['student_id' => 1, 'user_id' => rand(1, 4), 'name' => $faker->word, 'proficiency' => rand(0, 3), 'current' => true, 'note' => $faker->sentence(3)]);
     Skill::create(['student_id' => 1, 'user_id' => rand(1, 4), 'name' => $faker->word, 'proficiency' => rand(0, 3), 'current' => false, 'note' => $faker->sentence(3)]);
     Skill::create(['student_id' => 2, 'user_id' => rand(1, 4), 'name' => $faker->word, 'proficiency' => rand(0, 3), 'current' => $faker->boolean(20), 'note' => $faker->sentence(3)]);
     Skill::create(['student_id' => 2, 'user_id' => rand(1, 4), 'name' => $faker->word, 'proficiency' => rand(0, 3), 'current' => $faker->boolean(20), 'note' => $faker->sentence(3)]);
     Skill::create(['student_id' => 3, 'user_id' => rand(1, 4), 'name' => $faker->word, 'proficiency' => rand(0, 3), 'current' => $faker->boolean(20), 'note' => $faker->sentence(3)]);
     Skill::create(['student_id' => 4, 'user_id' => rand(1, 4), 'name' => $faker->word, 'proficiency' => rand(0, 3), 'current' => $faker->boolean(20), 'note' => $faker->sentence(3)]);
 }