Beispiel #1
0
 public function saveUserSkills(UserService $user, $user_id)
 {
     try {
         $inputs = Request::only('skill_ids', 'type');
         $skills = [];
         $skill_ids = $inputs['skill_ids'];
         for ($i = 0; $i < count($skill_ids); $i++) {
             $skill = [];
             if ($user->checkUserSkillArchive($user_id, $skill_ids[$i])) {
                 $skill = $user->restoreUserSkill($user_id, $skill_ids[$i]);
             } else {
                 if ($user->checkUserSkill($user_id, $skill_ids[$i])) {
                     $skill = $user->getUserSkill($user_id, $skill_ids[$i]);
                 } else {
                     $skill = $user->createUserSkill($user_id, $skill_ids[$i]);
                 }
             }
             if ($skill) {
                 $skills[] = $skill;
             }
         }
         if (count($skills) > 0 && !empty($skills)) {
             return $this->json_response->success($skills);
         }
         return $this->json_response->error();
     } catch (Exception $e) {
         return $this->json_response->error(['error' => $e->getMessage()]);
     }
 }