diff --git a/plugs/think-plugs-ticket/src/controller/UserShare.php b/plugs/think-plugs-ticket/src/controller/UserShare.php index 1b60e39..eeddc58 100644 --- a/plugs/think-plugs-ticket/src/controller/UserShare.php +++ b/plugs/think-plugs-ticket/src/controller/UserShare.php @@ -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']); }); } diff --git a/plugs/think-plugs-ticket/src/controller/api/auth/UserShare.php b/plugs/think-plugs-ticket/src/controller/api/auth/UserShare.php index 5956155..cf72d72 100644 --- a/plugs/think-plugs-ticket/src/controller/api/auth/UserShare.php +++ b/plugs/think-plugs-ticket/src/controller/api/auth/UserShare.php @@ -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); diff --git a/plugs/think-plugs-ticket/src/model/TicketUserShare.php b/plugs/think-plugs-ticket/src/model/TicketUserShare.php index 0c823d7..7342307 100644 --- a/plugs/think-plugs-ticket/src/model/TicketUserShare.php +++ b/plugs/think-plugs-ticket/src/model/TicketUserShare.php @@ -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();