| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 | 
							- <?php
 
- /**
 
-  * Created by PhpStorm.
 
-  * User: Administrator
 
-  * Date: 2018/12/4
 
-  * Time: 10:25
 
-  */
 
- namespace App\Repositories;
 
- use App\Models\Hotword;
 
- use Prettus\Repository\Eloquent\BaseRepository;
 
- /**
 
-  * Class HelpRepositoryEloquent.
 
-  *
 
-  * @package namespace App\Repositories;
 
-  */
 
- class HotWordRepository extends BaseRepository
 
- {
 
-     /**
 
-      * Specify Model class name
 
-      *
 
-      * @return string
 
-      */
 
-     public function model()
 
-     {
 
-         return Hotword::class;
 
-     }
 
-     public function getHotWords($where, $order = 'w_hot desc', $limit = '')
 
-     {
 
-         if ($limit) {
 
-             return $this->model->where($where)->orderByRaw($order)->limit($limit)->get();
 
-         } else {
 
-             return $this->model->where($where)->orderByRaw($order)->get();
 
-         }
 
-         //return $this->model->where($where)->orderByRaw($order)->get();
 
-     }
 
-     /**
 
-      * 搜索次数增加1,如果不存在则增加一条数据
 
-      */
 
-     public function setInc($word, $type)
 
-     {
 
-         $word = trim($word);
 
-         $word = substr($word, 0, 120);
 
-         $word_info = $this->model->where(array('w_word'=>$word,'type'=>$type))->first();
 
-         $stime = date('Y-m-d H:i:s', time());
 
-         if ($word_info) {
 
-             $this->model->where(array('id'=>$word_info->id))->increment('w_hot', 1);
 
-         } else {
 
-             $data = array(
 
-                 'w_word' => $word,
 
-                 'w_hot'  => 1,
 
-                 'type'   => $type,
 
-                 'created_at' => $stime,
 
-                 'updated_at' => $stime
 
-             );
 
-             $this->model->create($data);
 
-         }
 
-         return true;
 
-     }
 
- }
 
 
  |