如何在 Laravel-Slack Webhook 中动态附加多个图像?
How to attach multiple images dynamically in Laravel-Slack Webhook?
我正在尝试 post 在 Slack 通知中添加多张图片。它允许我手动添加“附件”但我想动态添加附件,即使用循环。
以下代码适用于手动附件:
return (new SlackMessage)->attachment(function (SlackAttachment $attachment) {
$attachment->title('Title1')
->image('Image1.jpg');
})
->attachment(function (SlackAttachment $attachment) {
$attachment->title('Title2')
->image('Image2.jpg');
});
但我不想手动传递“附件”,我想link根据循环次数自动传递“附件”。
我该如何解决这个问题?
像这样:
$message = new SlackMessage;
foreach($something as $something_else){
$message->attachment(function (SlackAttachment $attachment) {
$attachment->title('Title1')
->image('Image1.jpg');
})
}
return $message
我正在尝试 post 在 Slack 通知中添加多张图片。它允许我手动添加“附件”但我想动态添加附件,即使用循环。
以下代码适用于手动附件:
return (new SlackMessage)->attachment(function (SlackAttachment $attachment) {
$attachment->title('Title1')
->image('Image1.jpg');
})
->attachment(function (SlackAttachment $attachment) {
$attachment->title('Title2')
->image('Image2.jpg');
});
但我不想手动传递“附件”,我想link根据循环次数自动传递“附件”。
我该如何解决这个问题?
像这样:
$message = new SlackMessage;
foreach($something as $something_else){
$message->attachment(function (SlackAttachment $attachment) {
$attachment->title('Title1')
->image('Image1.jpg');
})
}
return $message