UserShare

This commit is contained in:
2024-11-30 16:42:04 +08:00
parent 08683c7fa0
commit a2cb1a01fa
3 changed files with 7 additions and 2 deletions

View File

@ -31,7 +31,7 @@ class UserShare extends Controller
$query->like(['title|content|ticket_address|contact_phone#keyword'])
->dateBetween(['create_at'])
->equal(['status', 'type_id']);
$query->with(['user'])->append(['imgs_arr', 'type_name']);
$query->append(['imgs_arr', 'type_name']);
});
}

View File

@ -40,7 +40,7 @@ class UserShare extends Auth
'ticket_address.require' => '地址不能为空',
'contact_name.default' => $this->account->user() ? $this->account->user()['nickname'] : '用户',
]);
$data['imgs'] = arr2str($data['imgs'], '|');
$data['imgs'] = str2arr($data['imgs'], '|');
$data['user_id'] = $this->usid;
$id = TicketUserShare::query()->insert($data, true);
$this->success('添加随手拍成功', $id);

View File

@ -11,6 +11,11 @@ class TicketUserShare extends Model
return str2arr($data['imgs'] ?: '', '|');
}
public function type()
{
return $this->belongsTo(TicketType::class, 'type_id', 'id');
}
public function getTypeNameAttr($value, $data)
{
$type = $this->type()->find();