1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- /**
- * Created by PhpStorm.
- * User: wuzhenke
- * Date: 2018/11/12
- * Time: 10:21
- */
- namespace App\Repositories;
- use App\Models\Jobs;
- use App\Models\MembersSetmeal;
- use Prettus\Repository\Criteria\RequestCriteria;
- use Prettus\Repository\Eloquent\BaseRepository;
- class MemberSetmealRepository extends BaseRepository
- {
- public function model()
- {
- return MembersSetmeal::class;
- }
- public function boot()
- {
- $this->pushCriteria(app(RequestCriteria::class));
- }
- public function getSetmealByUid($id, $utype)
- {
- return $this->model->where(['uid'=>$id,'utype'=>$utype])->first();
- }
- public function modifyJobsMeanwhile($id, $count, $type)
- {
- if ($type == 1) {
- return $this->model->where('id', $id)->increment('jobs_meanwhile', $count);
- } else {
- $jobs_meanwhile = $this->find($id, ['jobs_meanwhile']);
- if ($jobs_meanwhile->jobs_meanwhile>$count) {
- return $this->model->where('id', $id)->decrement('jobs_meanwhile', $count);
- } else {
- return $this->model->where('id', $id)->update(['jobs_meanwhile'=>0]);
- }
- }
- }
- public function updateSetmeal($sqlData, $id)
- {
- return $this->model->where(['id'=>$id])->update($sqlData);
- }
- public function incrementData($where, $filed, $num = 1)
- {
- return $this->model->where($where)->increment($filed, $num);
- }
- public function decrementData($where, $filed, $num = 1)
- {
- return $this->model->where($where)->decrement($filed, $num);
- }
- public function getMemberSetmeals($company_ids)
- {
- if ($company_ids) {
- return $this->model->whereIn('uid', $company_ids)->get();
- } else {
- return $this->model->get();
- }
- }
- public function checkSetmeals($where,$or){
- return $this->model->select("id")->where($where)->orWhere($or)->get();
- }
- }
|