2db47680
hexiaodong
chore: 初始提交 php 遗...
|
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
|
<?php
namespace addons\antis\model;
use think\Exception;
use think\Model;
use traits\model\SoftDelete;
/**
*重点关注表
*/
class StaffCollect Extends Model {
use SoftDelete;
// 表名,不含前缀
protected $name = 'qingdong_staff_collect';
const CUSTOMER_TYPE = 1;//客户
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
//添加重点关注
public static function addCollect($type, $id) {
$staff = Staff::info();
$data = [
'relation_type' => $type,
'relation_id' => $id,
'staff_id' => $staff->id
];
$Model = new self;
// 调用当前模型对应的User验证器类进行数据验证
$result = $Model->save($data);
if (false === $result) {
// 验证失败 输出错误信息
throw new Exception($Model->getError());
}
return true;
}
//取消重点关注
public static function cancel($type, $id) {
$Model = new self;
// 调用当前模型对应的User验证器类进行数据验证
$result = $Model->destroy(['relation_type' => $type, 'relation_id' => $id]);
if (false === $result) {
// 验证失败 输出错误信息
throw new Exception($Model->getError());
}
return true;
}
//是否重点关注
public static function isCollect($type, $id) {
$staff = Staff::info();
$where = [
'relation_type' => $type,
'relation_id' => $id,
'staff_id' => $staff->id
];
$Model = new self;
// 调用当前模型对应的User验证器类进行数据验证
if ($Model->where($where)->find()) {
return true;
}
return false;
}
}
|