update:微信回复
This commit is contained in:
@@ -28,6 +28,13 @@ class WechatReplyRepository extends CatchRepository
|
||||
return $this->reply;
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储
|
||||
*
|
||||
* @time 2020年09月13日
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function storeBy(array $data)
|
||||
{
|
||||
$material = WeChat::officialAccount()->material;
|
||||
@@ -55,6 +62,41 @@ class WechatReplyRepository extends CatchRepository
|
||||
return parent::storeBy($data); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @time 2020年09月13日
|
||||
* @param int $id
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function updateBy(int $id, array $data)
|
||||
{
|
||||
$material = WeChat::officialAccount()->material;
|
||||
|
||||
$mediaUrl = $this->getLocalPath($data['media_url'] ?? '');
|
||||
$imageUrl = $this->getLocalPath($data['image_url'] ?? '');
|
||||
|
||||
if ($imageUrl) {
|
||||
// 音乐
|
||||
if ($data['type'] == WechatReply::MUSIC) {
|
||||
$data['media_id'] = $material->uploadThumb($imageUrl)['media_id'];
|
||||
} else {
|
||||
// $data['media_id'] = $material->uploadImage($imageUrl)['media_id'];
|
||||
}
|
||||
}
|
||||
// 语音
|
||||
if ($data['type'] == WechatReply::VOICE) {
|
||||
$data['media_id'] = $material->uploadVoice($mediaUrl)['media_id'];
|
||||
}
|
||||
// 视频
|
||||
if ($data['type'] == WechatReply::VIDEO) {
|
||||
$data['media_id'] = $material->uploadVideo($mediaUrl, $data['title'], $data['content'])['media_id'];
|
||||
}
|
||||
|
||||
return parent::updateBy($id, $data); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本地地址
|
||||
*
|
||||
|
Reference in New Issue
Block a user