| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 | <?php/** * Created by PhpStorm. * User: wuzhenke * Date: 2018/11/12 * Time: 19:09 */namespace App\Repositories;use App\Models\SetmealIncrement;use Prettus\Repository\Criteria\RequestCriteria;use Prettus\Repository\Eloquent\BaseRepository;use Illuminate\Support\Facades\Cache;class SetmealIncrementsRepository extends BaseRepository{    //增值包单位    public $service_unit = array('download_resume' => '条', 'sms' => '条', 'stick' => '天', 'emergency' => '天', 'auto_refresh_jobs' => '次','jobfair_num'=>'次','jobs'=>'条');    public $cate_arr = ['download_resume' => '简历增值包','jobs'=>'职位增值包','jobfair_num'=>'招聘会场次增值包', 'sms' => '短信增值包', 'stick' => '职位置顶', 'emergency' => '职位紧急', 'tpl' => '企业模板', 'auto_refresh_jobs' => '职位智能刷新'];    public function model()    {        return SetmealIncrement::class;    }    public function boot()    {        $this->pushCriteria(app(RequestCriteria::class));    }    public function getCat($cat)    {        return $this->model->where(['cat'=>$cat])->first();    }    public function getIncrement($id)    {        return $this->model->where(['id'=>$id])->first();    }    public function getIncrementCache($cat = '', $id = 0)    {        //除掉缓存        $rst = $this->model->orderBy('sort', 'desc')->get();        $cache = null;        if ($rst) {            foreach ($rst as $k => $v) {                $cache[$v->id] = $v;            }        }        if ($cat <> '') {            $return = array();            foreach ($cache as $key => $value) {                if ($value->cat == $cat) {                    $return[] = $value;                }            }        } else {            $return = $cache;        }        if ($id > 0) {            return $return[$id];        } else {            return $return;        }    }    public function getIncrementCategory()    {        return $this->model->select(['cat'])->groupBy('cat')->get();    }}
 |