Style.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace app\common\model;
use think\Model;
class Style extends Model
{
/**
* 获取风格列表
*/
public static function styleList($style_template_id){
// 一级风格
$list = self::getStyleList(['style_template_id'=>$style_template_id,'pid'=>0,'display_mode'=>'1']);
return $list;
}
/**
* 获取风格列表
*/
public static function getStyleList($where){
$list = self::where($where)
->order('weigh asc')
->select();
foreach($list as $v){
$v['style_value_list'] = self::getStyleValueList($v['id']);
$v['two_style_list'] = self::getStyleList(['pid'=>$v['id']]);
$v->visible(['id','style_name','style_type','display_mode'])->append(['style_value_list','two_style_list']);
}
$list = collection($list)->toArray();
return $list;
}
/**
* 获取选项列表
*/
public static function getStyleValueList($style_id){
$list = StyleValue::where('style_id',$style_id)
->order('weigh asc')
->select();
foreach($list as $v){
$v['style_list'] = self::getStyleList(['id'=>['in',$v['style_ids']]]);
$v->visible(['id','style_id','style_value_name','style_value_image','style_value_desc','style_ids'])->append(['style_list']);
}
$list = collection($list)->toArray();
return $list;
}
}