示例#1
0
 public function getDatas($genre, $keyword)
 {
     //genre==1创作,2样片,3创意,4分镜,5企业,6影视,7演员,8设备,9设计,
     $datas = SearchModel::where('genre', $genre)->where('keyword', 'like', '%' . $keyword . '%')->get();
     $searchIds = array();
     if (count($datas)) {
         foreach ($datas as $data) {
             $searchIds[] = $data->fromid;
             //处理关键字才行频率
             if (SearchKeywordModel::where('search_id', $data->id)->first()) {
                 //假如有记录,更新频率 rate
                 SearchKeywordModel::where('search_id', $data->id)->update(array('updated_at' => time()));
                 SearchKeywordModel::where('search_id', $data->id)->increment('rate');
             } else {
                 $searchKeyword = ['search_id' => $data->id, 'keyword' => $keyword, 'created_at' => time()];
                 SearchKeywordModel::create($searchKeyword);
             }
         }
     }
     if ($genre == 1) {
         $datas = ProductModel::whereIn('id', $searchIds)->orderBy('id', 'desc')->paginate($this->limit);
         $datas->url = DOMAIN . 'creation/';
     } elseif ($genre == 2) {
         $datas = GoodsModel::whereIn('id', $searchIds)->orderBy('id', 'desc')->paginate($this->limit);
         $datas->url = DOMAIN . 'product/';
     } elseif ($genre == 3) {
         $datas = IdeasModel::whereIn('id', $searchIds)->orderBy('id', 'desc')->paginate($this->limit);
         $datas->url = DOMAIN . 'idea/';
     } elseif ($genre == 4) {
         $datas = StoryBoardModel::whereIn('id', $searchIds)->orderBy('id', 'desc')->paginate($this->limit);
         $datas->url = DOMAIN . 'storyboard/';
     } elseif ($genre == 5) {
         $datas = CompanyModel::whereIn('id', $searchIds)->orderBy('id', 'desc')->paginate($this->limit);
         $datas->url = DOMAIN . 'company/';
     } elseif ($genre == 6) {
         $datas = WorksModel::whereIn('id', $searchIds)->orderBy('id', 'desc')->paginate($this->limit);
         $datas->url = DOMAIN . 'entertain/works/show/';
     } elseif ($genre == 7) {
         $datas = StaffModel::whereIn('id', $searchIds)->orderBy('id', 'desc')->paginate($this->limit);
         $datas->url = DOMAIN . 'entertain/staff/show/';
     } elseif ($genre == 8) {
         $datas = RentModel::whereIn('id', $searchIds)->orderBy('id', 'desc')->paginate($this->limit);
         $datas->url = DOMAIN . 'rent/';
     } elseif ($genre == 9) {
         $datas = DesignModel::whereIn('id', $searchIds)->orderBy('id', 'desc')->paginate($this->limit);
         $datas->url = DOMAIN . 'design/';
     }
     $datas->limit = $this->limit;
     return $datas;
 }
示例#2
0
 /**
  * 获取热门词汇
  */
 public static function getHotWords()
 {
     return SearchKeywordModel::orderBy('rate', 'desc')->paginate(5);
 }