123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace App\Repositories;
- use App\Models\Hotword;
- use Prettus\Repository\Eloquent\BaseRepository;
- class HotWordRepository extends BaseRepository
- {
-
- 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();
- }
-
- }
-
- 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;
- }
- }
|