ShowModel.php
2.0 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* Author : xiaojie
* DateTime: 2018/11/29 10:06
*/
namespace app\portal\model;
use think\Model;
use traits\model\SoftDelete;
class ShowModel extends Model
{
protected $autoWriteTimestamp = true;
protected $type = [
'files' => 'array',
];
/**
* content 自动转化
* @param $value
* @return string
*/
public function getContentAttr($value){
return cmf_replace_content_file_url(htmlspecialchars_decode($value));
}
/**
* 获取列表信息
* ->paginate(10,false,['query'=>$page_arr])
* @param $cate_id 分类id
* @param string $keyword 关键词查询
* @param string $order 排序
* @return \think\Paginator
*/
public function getList($cate_id,$keyword='' ,$page_num = '4',$order = 'id DESC')
{
if($keyword){
$map['title'] = ['like',"%$keyword%"];
}
if(is_array($cate_id)){
$map['cate_id'] = ['in',$cate_id];
}else{
$map['cate_id'] = $cate_id;
}
$list = $this
->where($map)
->order($order)
->paginate($page_num);
return $list;
}
/**
* 获取移动端的列表数据
* @param $cate_id
* @param string $page_num
* @param string $order
* @return \think\Paginator
*/
public function getMobileList($cate_id,$page,$page_num = '10',$order = 'id DESC')
{
if(is_array($cate_id)){
$map['cate_id'] = ['in',$cate_id];
}else{
$map['cate_id'] = $cate_id;
}
$list = $this
->where($map)
->order($order)
->limit($page_num)
->page($page)
->select();
return $list;
}
/**
* 获取详情
* @param $id
* @return array|false|\PDOStatement|string|Model
*/
public function getDetail($id)
{
$info = $this->where('id',$id)->find();
return $info;
}
}