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