Notices.php
1.5 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
<?php
namespace addons\facrm\model;
class Notices extends \app\admin\model\facrm\Notices
{
/**
* 添加通知
* @param $content
* @param $engine
* @param int $admin_id
* @param int $customer_id
* @param int $status
* @param int $user_id
*/
public static function add($content="", $engine="", $status = 0, $msg = "", $extend = [])
{
$insert_data = [
'content' => is_array($content) ? json_encode($content, JSON_UNESCAPED_UNICODE) : $content,
'engine' => $engine,
'status' => $status,
'msg' => $msg,
'customer_id' => 0,
'admin_id' => 0,
'user_id' => 0,
'create_time' => time(),
];
$insert_data = array_merge($insert_data, $extend);
return self::create($insert_data);
}
/**
* 编辑或添加
* @param $event_id
* @param $extend
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function edit($event_id, $extend)
{
$row = self::where('event_id', $event_id)->find();
if ($row) {
return $row->save($extend);
} else {
$extend['event_id']=$event_id;
$extend['content']=isset($extend["content"])&& is_array($extend["content"]) ? json_encode($extend["content"] ,JSON_UNESCAPED_UNICODE) : "";
return self::add("", "", 0,"",$extend);
}
}
}