コード例 #1
0
ファイル: CompanyJob.php プロジェクト: Worklemon/api
 public function getMatchCountAttribute()
 {
     $skill_ids = [];
     foreach ($this->job_skills as $job_skill) {
         $skill_ids[] = $job_skill['skill_id'];
     }
     if (count($skill_ids) > 0) {
         $user_ids = UserSkill::select(DB::raw('DISTINCT(user_id)'))->whereIn('skill_id', $skill_ids)->get()->toArray();
         $lat = $this->job_locations->lat;
         $lng = $this->job_locations->lng;
         $users = User::within((int) $this->search_radius, 'kilometers', $lat, $lng)->where('lat', '!=', '')->where('lng', '!=', '')->whereIn('id', $user_ids)->get();
         return count($users);
     }
     return 0;
 }