public function getMatchRateAttribute() { if (Session::has('job_id')) { $job_skills = CompanyJobSkill::with('skill')->where('job_id', '=', Session::get('job_id'))->get()->toArray(); $user_skills = $this->skills()->toArray(); if (count($user_skills) > 0) { $skill_percentage = 0; $job_traits = 0; $user_traits = 0; foreach ($job_skills as $job_skill) { $avg_user_job_rate = 0; foreach ($user_skills as $user_skill) { if ($job_skill['skill_id'] == $user_skill['skill_id']) { if ($user_skill['skill']['type'] == 'soft') { $user_traits++; } if ($user_skill['skill']['type'] == 'hard') { if ($user_skill['rate'] >= $job_skill['rate']) { $avg_user_job_rate = 1; } else { $avg_user_job_rate = $user_skill['rate'] / $job_skill['rate']; } $over_all_skill_match = $avg_user_job_rate * 100 * ($job_skill['importance'] / 100); $skill_percentage += $over_all_skill_match; } } } if ($job_skill['skill']['type'] == 'soft') { $job_traits++; } } $trait_percentage = 0; if ($job_traits !== 0) { $trait_percentage = $user_traits / $job_traits * 100 * ($this->traits_importance / 100); } $skill_percentage = $skill_percentage * ((100 - $this->traits_importance) / 100); return round($trait_percentage + $skill_percentage); } else { return 0; } } return '0'; }
public function getAllCompanyJobSkillsByType($job_id, $skill_ids) { try { return CompanyJobSkill::with('skill')->where('job_id', '=', $job_id)->whereIn('skill_id', $skill_ids)->get()->toArray(); } catch (Exception $e) { return Response::json(['error' => $e->getMessage()]); } }