<?php namespace App\Repositories; use App\Models\MembersHandsel; use Prettus\Repository\Eloquent\BaseRepository; use Prettus\Repository\Criteria\RequestCriteria; /** * Class MemberRepositoryEloquent. * * @package namespace App\Repositories; */ class MemberHandselRepository extends BaseRepository { /** * Specify Model class name * * @return string */ public function model() { return MembersHandsel::class; } /** * Boot up the repository, pushing criteria */ public function boot() { $this->pushCriteria(app(RequestCriteria::class)); } public function addNew($data) { return $this->model->create($data); } /**积分操作明细 * @param $uid * @param $utype * @return mixed */ public function getMembersHandsel($uid, $utype, $type) { $where['uid'] = $uid; $where['utype'] = $utype; if ($type != 3) { $where['operate'] = $type; } return $this->model->where($where)->orderBy('created_at', 'desc')->paginate(10, ['*']); } public function getNum($user, $type = 1) { $where['uid'] = $user->id; $where['utype'] = $user->utype; $where['operate'] = $type; return $this->model->where($where)->selectRaw('sum(points)as getTotalPoints')->get(); } }