|
@@ -31,6 +31,10 @@ class Category extends Model
|
|
|
return is_array($value) ? implode(',', $value) : $value;
|
|
|
}
|
|
|
|
|
|
+ public function goods(){
|
|
|
+ return $this->hasMany(Goods::class)->where('status',1);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 读取分类类型
|
|
|
* @return array
|
|
@@ -70,7 +74,7 @@ class Category extends Model
|
|
|
* @param string $status 指定状态
|
|
|
* @return array
|
|
|
*/
|
|
|
- public static function getCategoryArray($type = null, $status = null)
|
|
|
+ public static function getCategoryArray($type = null, $status = null,$with=[])
|
|
|
{
|
|
|
$list = collection(self::where(function ($query) use ($type, $status) {
|
|
|
if (!is_null($type)) {
|
|
@@ -79,11 +83,11 @@ class Category extends Model
|
|
|
if (!is_null($status)) {
|
|
|
$query->where('status', '=', $status);
|
|
|
}
|
|
|
- })->order('weigh', 'desc')->select())->toArray();
|
|
|
+ })->order('weigh', 'desc')->with($with)->select())->toArray();
|
|
|
return $list;
|
|
|
}
|
|
|
|
|
|
- public static function mall(){
|
|
|
- return self::getCategoryArray('mall');
|
|
|
+ public static function mall($with=[]){
|
|
|
+ return self::getCategoryArray('mall','normal',$with);
|
|
|
}
|
|
|
}
|