<?php

namespace App\Repositories;

use App\Models\PersonFocusCompany;
use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;

/**
 * Class MemberRepositoryEloquent.
 *
 * @package namespace App\Repositories;
 */
class PersonFocusComRepository extends BaseRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return PersonFocusCompany::class;
    }

    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }

    public function getAttionCom($data,$where)
    {
        return $this->model->with(['jobs'=>function($query) use ($where) {
            $query->whereIn('audit', $where)->where('display', 1)->where('valid', 1);
            $query->whereHas('subsiteJobs',function ($query){
                $query->where('subsite_id',get_subsite_id());
            });
        },'companys'])->whereHas('companys')->where($data)->orderBy('id', 'desc')->paginate(4);
    }

    public function concern($where, $page = 10)
    {
        return $this->model->with('resumes')->Where($where)->paginate($page);
    }

    public function concernDel($ids,$company_id)
    {
        return $this->model->whereIn('id', $ids)->where("company_id",$company_id)->delete();
    }

    //获取企业粉丝数量
    public function getFansCount($where)
    {
        return $this->model->where($where)->count();
    }
    public function getFocus($where)
    {
        return $this->model->where($where)->first();
    }
    public function deleteFocus($where)
    {
        return $this->model->where($where)->delete();
    }
    public function addFocus($data)
    {
        return $this->model->create($data);
    }


}