123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- /**
- * 产品属性
- * @author system
- * @version 1.0
- * @date 2018-07-03 16:51:48
- *
- */
- namespace App\Repositories\Album\Product;
- use App\Repositories\Base\Repository;
- class AttrRepository extends Repository {
- public function model() {
- return \App\Models\AlbumProductAttrModel::class;
- }
- public function searchAttr(array $search,array $orderby=['id'=>'desc'],$pagesize=10)
- {
- $currentQuery = $this->model;
- if(isset($search['keyword']) && ! empty($search['keyword'])) {
- $keywords = '%' . $search['keyword'] . '%';
- $currentQuery = $currentQuery->where(function ($query) use ($keywords) {
- $query->where('id' , 'like', $keywords)
- ->orwhere('name', 'like', $keywords);
- });
- }
- $currentQuery = $currentQuery->where(function ($query) use ($search) {
- $query->where('store_id',$search['storeid']);
- });
- if($orderby && is_array($orderby)){
- foreach ($orderby AS $field => $value){
- $currentQuery = $currentQuery -> orderBy($field, $value);
- }
- }
- $currentQuery = $currentQuery->paginate($pagesize);
- return $currentQuery;
- }
- }
|