Browse Source

更换整合数组的方法

master
liangyuyan 5 years ago
parent
commit
28604db40f
  1. 2
      app/Models/v3/Category.php
  2. 7
      app/Models/v3/CouponSetting.php
  3. 5
      app/Models/v3/GoodsCategory.php
  4. 11
      app/Models/v3/Market.php

2
app/Models/v3/Category.php

@ -61,7 +61,7 @@ class Category extends Model
$new = array_merge($options,$list);
return array_flip($new);
}else{
return $list;
return array_flip($list);
}
}

7
app/Models/v3/CouponSetting.php

@ -41,11 +41,12 @@ class CouponSetting extends Model
if(!empty($where)){
$model->where($where);
}
$list = $model->pluck('name','id')->toArray();
$list = $model->pluck('id','name')->toArray();
if(!empty($options)){
return array_merge($options,$list);
$new = array_merge($options,$list);
return array_flip($new);
}else{
return $list;
return array_flip($list);
}
}

5
app/Models/v3/GoodsCategory.php

@ -40,9 +40,10 @@ class GoodsCategory extends Model
if(count($where) > 0){
$model->where($where);
}
$list = $model->pluck('title','id')->toArray();
$list = $model->pluck('id','title')->toArray();
if(!empty($options)){
return array_merge($options,$list);
$new = array_merge($options,$list);
return array_flip($new);
}else{
return $list;
}

11
app/Models/v3/Market.php

@ -34,17 +34,18 @@ class Market extends Model
*/
public static function getMarketArray($where = [], $options = [])
{
$model = self::where('status',1)
->whereNull('deleted_at');
$model = self::whereNull('deleted_at');
// ->where('status',1)
if(!empty($where)){
$model->where($where);
}
$list = $model->pluck('name','id')->toArray();
$list = $model->pluck('id','name')->toArray();
if(!empty($options)){
return array_merge($options,$list);
$new = array_merge($options,$list);
return array_flip($new);
}else{
return $list;
return array_flip($list);
}
}

Loading…
Cancel
Save