GoodsModel.php
1.7 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
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <bronet@126.com>
// +----------------------------------------------------------------------
namespace app\portal\model;
use think\Model;
use traits\model\SoftDelete;
class GoodsModel extends Model
{
use SoftDelete;
protected $pk='id';
protected $autoWriteTimestamp = 'true';
public function goodsCategory()
{
return $this->belongsTo('GoodsCategoryModel','category_id','id');
}
//查询范围
// public function scopeName($query, $name)
// {
// $query->where('name', 'like', '%' . $name . '%');
// }
// 定义全局的查询范围
// protected function base($query)
// {
// $query->where('status',1);
// }
//类型转换
// protected $type = [
// 'more' => 'type',
// ];
//自动完成
// protected $auto = ['name', '测试商品啦'];
// protected $insert = ['status' => 0];
// protected $update = [];
//只读字段
// protected $readonly = ['id'];
//获取器
function getStatusAttr($value){
$status = [0=>'下架',1=>'上架',2=>'售空'];
return $status[$value];
// $status = [0=>'下架',1=>'上架',2=>'售空'];
// return $status[$data['status']];
}
public function index(){
}
}