<?php

namespace App\Repositories;

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

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

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

    public function getJobsSub($data)
    {
        return $this->model->where($data)->orderBy('id', 'desc')->get();
    }

    public function getJobsSubAdd($data)
    {
        return $this->model->create($data);
    }

    public function getJobsById($id)
    {
        return $this->model->find($id);
    }

    public function getJobsSubUpdate($data, $id)
    {
        return $this->model->where('id', $id)->update($data);
    }

    public function getJobsAddVar($data)
    {
        return $this->model->where($data)->count();
    }

    public function getJobsSubDel($id)
    {
        return $this->model->where('id', $id)->delete();
    }

    public function rateDate($data)
    {
        return $this->model->where($data)->where('updated_at', '>=', date('Y-m-d 00:00:00'))
            ->where('updated_at', '<=', date('Y-m-d 23:59:59'))->get();
    }

    public function rateDateCount($data)
    {
        return $this->model->where($data)->select('*')->count();
    }

    public function getPersonJobsSub($where)
    {
        return $this->model->where($where)->first();
    }
}