| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 | <?phpnamespace App\Repositories;use App\Models\Recuperate;use Prettus\Repository\Eloquent\BaseRepository;class RecuperateRepository extends BaseRepository{    /**     * Specify Model class name     *     * @return string     */    public function model()    {        return Recuperate::class;    }    /**     * @param $where array     * @return null|\Illuminate\Database\Eloquent\Model     */    public function getRecuperate($where, $page)    {        $res = $this->model->where($where)->orderByRaw('list_order desc,created_at desc');        if ($page) {            return $res->paginate($page);        } else {            return $res->get();        }    }    /**     * @param $where array     * @return null|\Illuminate\Database\Eloquent\Model     */    public function getAllRecuperate($where, $orWhere, $page)    {        $res = $this->model->where(function ($query) use ($where, $orWhere) {            $query->where($where)->orwhere($orWhere);        })->orderByRaw('list_order desc,created_at desc');        if ($page) {            return $res->paginate($page);        } else {            return $res->get();        }    }    public function firstWhere($where)    {        return $this->model->where($where)->first();    }    public function incrementData($where, $num, $filed)    {        return $this->model->where($where)->increment($filed, $num);    }    public function filterRecuperate($where = array(), $whereIn = array(), $order = array())    {        $rst = $this->model->where($where);        if ($whereIn) {            foreach ($whereIn as $k => $v) {                $rst->whereIn($k, $v);            }        }        if ($order) {            if (is_array($order)) {                foreach ($order as $k => $v) {                    $rst->orderBy($k, $v);                }            } else {                $rst->orderbyRaw($order);            }        }        return $rst->get();    }}
 |