| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 | <?php/** * Created by PhpStorm. * User: wuzhenke * Date: 2019/1/22 * Time: 15:42 */namespace App\Repositories\Jobfair;use App\Models\Jobfair\JobfairJob;use Prettus\Repository\Criteria\RequestCriteria;use Prettus\Repository\Eloquent\BaseRepository;class JobfairJobRepository extends BaseRepository{    public function model()    {        return JobfairJob::class;    }    public function boot()    {        $this->pushCriteria(app(RequestCriteria::class));    }    public function getJobList($where)    {        return $this->model->where($where)->orderByRaw('field(audit,2,1,3)')->orderBy('updated_at', 'desc')->paginate(10);    }    public function editJob($id)    {        return $this->model->with('jobsContact')->where('id', $id)->first();    }    public function store($jobData)    {        return  $this->model->create($jobData);    }    public function deleteJobs($where, $ids)    {        return $this->model->where($where)->whereIn('id', $ids)->delete();    }    public function getCount($where)    {        return $this->model ->when(get_subsite_id()>0, function ($query) {            $query->whereHas('company', function ($query) {                $query->where('companys.subsite_id', get_subsite_id());            });        })->where($where)->count();    }    public function displayswitch($id, $display)    {        return $this->model->where('id', $id)->update(['display'=>$display]);    }    /**     * 根据条件删除     * @param $where     * @return mixed     */    public function delJobs($column, $ids)    {        return $this->model->whereIn($column,$ids)->delete();    }    public function getAuditJobList($where)    {        return $this->model->where($where)->orderBy('id', 'desc')->get();    }    public function getJobs($where)    {        return $this->model->where($where)->get();    }    public function getCrmJobs($where, $whereIn = [], $order_by = '', $offset = '', $limit = '')    {        $rst = $this->model->with(['company'])->whereHas('company')->where($where);        if ($whereIn) {            foreach ($whereIn as $k => $v) {                $rst->whereIn($k, $v);            }        }        if ($order_by) {            $rst->orderByRaw($order_by);        }        if ($offset !='' && $limit!='') {            $rst->offset($offset)->limit($limit);        };        return $rst->get();    }    public function getCrmInfo ($where)    {        return $this->model->with(['company','contact'])->where($where)->first();    }    public function getCrmJobCount($where, $where_in = [])    {        $rst = $this->model->whereHas('company')->where($where);        if ($where_in) {            foreach ($where_in as $k => $v) {                $rst->whereIn($k, $v);            }        }        return $rst->count();    }    public function getColumn($where,$column)    {        return $this->model->where($where)->value($column);    }    public function getPluck($where,$column)    {        return $this->model->where($where)->pluck($column);    }}
 |