-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoReply.php
More file actions
77 lines (62 loc) · 1.71 KB
/
AutoReply.php
File metadata and controls
77 lines (62 loc) · 1.71 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
<?php
namespace App\Models\Setting;
use Illuminate\Database\Eloquent\Model;
class AutoReply extends Model
{
const STATUS_OPEN = 'open';
const STATUS_CLOSE = 'close';
protected $table = 'setting_auto_reply';
protected $fillable = ['welcome', 'timeout', 'bye', 'team_id'];
protected $casts = [
'id' => 'integer',
'team_id' => 'integer'
];
public function getWelcomeAttribute($json)
{
$arr = json_decode($json, true);
if (empty($arr['message'])) {
$arr['message'] = '请问有什么可以帮助您?';
}
return $arr;
}
public function getTimeoutAttribute($json)
{
$arr = json_decode($json, true);
if (empty($arr['message'])) {
$arr['message'] = '客服忙碌,请稍等';
}
return $arr;
}
public function getByeAttribute($json)
{
$arr = json_decode($json, true);
if (empty($arr['message'])) {
$arr['message'] = '对话结束';
}
return $arr;
}
public function getOffworkAttribute($json)
{
$arr = json_decode($json, true);
if (empty($arr['message'])) {
$arr['message'] = '对话结束';
}
return $arr;
}
public function setWelcomeAttribute($array)
{
$this->attributes['welcome'] = json_encode($array);
}
public function setTimeoutAttribute($array)
{
$this->attributes['timeout'] = json_encode($array);
}
public function setByeAttribute($array)
{
$this->attributes['bye'] = json_encode($array);
}
public function setOffworkAttribute($array)
{
$this->attributes['offwork'] = json_encode($array);
}
}