123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- namespace App\Repositories;
- use App\Models\CompanyFavorite;
- use Prettus\Repository\Eloquent\BaseRepository;
- use Prettus\Repository\Criteria\RequestCriteria;
- /**
- * Class MemberRepositoryEloquent.
- *
- * @package namespace App\Repositories;
- */
- class companyFavoriteRepository extends BaseRepository
- {
- /**
- * Specify Model class name
- *
- * @return string
- */
- public function model()
- {
- return CompanyFavorite::class;
- }
- /**
- * Boot up the repository, pushing criteria
- */
- public function boot()
- {
- $this->pushCriteria(app(RequestCriteria::class));
- }
- public function getAttentionsMe($uid, $settr)
- {
- if ($settr) {
- $res= $this->model->with(['resumes','companys'])->whereHas('resumes', function ($query) use ($uid) {
- $query->whereIn('id', $uid);
- })->whereHas('companys')->where($settr)->orderBy('id', 'desc')->paginate(5);
- } else {
- $res= $this->model->with(['resumes','companys'])->whereHas('resumes', function ($query) use ($uid) {
- $query->whereIn('id', $uid);
- })->whereHas('companys')->orderBy('id', 'desc')->paginate(5);
- }
- return $res;
- }
- public function delAttention($id)
- {
- return $this->model->whereIn('id', $id)->delete();
- }
- public function getAttentionByResume($resume_id)
- {
- return $this->model->where('resume_id', $resume_id)->count();
- }
- /**
- * 企业收藏的简历
- * @param $where
- * @param $page
- * @return mixed
- */
- public function favorityList($where, $map, $id, $page)
- {
- return $this->model->when($map, function ($query) use ($map) {
- $query->whereHas('resumes', function ($querys) use ($map) {
- $querys->where($map);
- });
- })->where($where)->where('company_id', $id)->orderBy('created_at', 'desc')->paginate($page, ['*']);
- // return $this->model->with(['resumes'=>function ($query) use ($map) {
- // $query->where($map);
- // }])->where($where)->whereHas('resumes')->where('company_id', $id)->orderBy('created_at', 'desc')->paginate($page, ['*']);
- }
- /**删除企业收藏的简历
- * @param $ids
- * @return mixed
- * @param $company_id
- */
- public function favoritesResumeDel($ids,$company_id)
- {
- return $this->model->whereIn('id', $ids)->where("company_id",$company_id)->delete();
- }
- public function findFavorite($resume_id, $company_id)
- {
- $where['resume_id'] = $resume_id;
- $where['company_id'] = $company_id;
- return $this->model->where($where)->first();
- }
- public function cancelFavor($where)
- {
- return $this->model->where($where)->delete();
- }
- public function getFavoritesResumes($where)
- {
- return $this->model->where($where)->get();
- }
- public function insertData($data)
- {
- return $this->model->insert($data);
- }
- }
|