示例#1
0
 private static function processKeywords(Job $jobObj, $record_status, $old_keywords = null)
 {
     //  remove current keywords from caches
     if ($record_status == 'existed' && !empty($old_keywords)) {
         $job_keywords = explode(',', $old_keywords);
         foreach ($job_keywords as $jkw) {
             Keyword::removeJobFromKeywordCache($jkw, $jobObj->id);
         }
         $jobObj->keywords()->detach();
     }
     if ($record_status == 'new' || !empty($old_keywords)) {
         $keywords = self::generateJobKeywords($jobObj->title);
         if (!empty($keywords)) {
             foreach ($keywords as $kw) {
                 $score = strtotime($jobObj->updated_at);
                 if ($jobObj->is_featured == 1) {
                     $score = $score * 3;
                 }
                 Keyword::saveInstance(['keyword' => $kw, 'job_id' => $jobObj->id, 'score' => $score]);
             }
         }
     }
 }