You've already forked guangan
分类
This commit is contained in:
@ -6,88 +6,4 @@ class TicketTicketInter extends TicketTicket
|
||||
{
|
||||
protected $globalScope = ['inter'];
|
||||
protected $table = 'ticket_ticket';
|
||||
public function type()
|
||||
{
|
||||
return $this->belongsTo(TicketType::class, 'type_id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->morphTo('user');
|
||||
}
|
||||
|
||||
public function reply()
|
||||
{
|
||||
return $this->hasMany(TicketReply::class, 'ticket_id')->order("create_at", 'asc');
|
||||
}
|
||||
|
||||
public function getImgsArrAttr($value, $data)
|
||||
{
|
||||
if (!empty($data['imgs'])) {
|
||||
return str2arr($data['imgs'] ?: '', '|');
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public function getLastReplyAttr($value, $data)
|
||||
{
|
||||
return $this->reply()->order('create_at', 'desc')->find();
|
||||
}
|
||||
|
||||
public function getSourceTypeNameAttr($value, $data)
|
||||
{
|
||||
if (!empty($this->getSourceTypeList()[$data['source_type']])) {
|
||||
return $this->getSourceTypeList()[$data['source_type']];
|
||||
} else {
|
||||
return '未知';
|
||||
}
|
||||
}
|
||||
|
||||
public function getSourceTypeList()
|
||||
{
|
||||
return [
|
||||
0 => '其他',
|
||||
1 => '用户随手拍',
|
||||
2 => '工单',
|
||||
];
|
||||
}
|
||||
|
||||
public function getTypeNameAttr($value, $data)
|
||||
{
|
||||
$type = $this->type()->find();
|
||||
if (!empty($type)) {
|
||||
return $type['name'];
|
||||
} else {
|
||||
return '未知';
|
||||
}
|
||||
}
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
if (!empty($this->getStatusList()[$data['status']])) {
|
||||
return $this->getStatusList()[$data['status']];
|
||||
} else {
|
||||
return '未知';
|
||||
}
|
||||
}
|
||||
|
||||
private function getStatusList()
|
||||
{
|
||||
return [
|
||||
-1 => '已关闭',
|
||||
0 => '待处理',
|
||||
1 => '已作处理',
|
||||
];
|
||||
}
|
||||
|
||||
public function scopeAvail($query)
|
||||
{
|
||||
return $query->where('status', '>=', '0');
|
||||
}
|
||||
|
||||
public function userShares()
|
||||
{
|
||||
return $this->hasMany(TicketUserShare::class, 'linked_ticket_id');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user