10月CMS |使用按钮发送从字段检索到的电子邮件
我正在尝试动态地查找电子邮件地址(从字段中输入的内容),然后将电子邮件发送到该地址。
到目前为止,我已经能够获取按钮发送电子邮件,但无法从模型中检索地址。
示例:
控制器
public function onSend()
{
// Retrieve email address from Machines model in email field
$this->vars['email'] = Machines::get('email');
// Send to email address using partial button
Mail::send('martin.maintenance::mail.maintenancereminder', [], function($message) {
$message->to($this->vars['email']);
});
}
字段(机器模型)
email:
label: 'Email Address'
span: auto
type: text
tab: Details
部分(按钮)
<button
type="submit"
data-request="onSend"
class="btn btn-primary">
Reminder
</button>
很高兴提供任何其他信息。提前致谢!
I'm trying to dynamically find email address (from what has been inputted in a field), then sending out email to that address.
So far, I have been able to get the button to send emails but unable to retrieve the address from model.
Examples:
Controller
public function onSend()
{
// Retrieve email address from Machines model in email field
$this->vars['email'] = Machines::get('email');
// Send to email address using partial button
Mail::send('martin.maintenance::mail.maintenancereminder', [], function($message) {
$message->to($this->vars['email']);
});
}
Field (in Machines model)
email:
label: 'Email Address'
span: auto
type: text
tab: Details
Partial (button)
<button
type="submit"
data-request="onSend"
class="btn btn-primary">
Reminder
</button>
Happy to provide any additional info. Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定您的代码中哪一部分触发了该错误,但是我怀疑这与
:: get('email')
返回的内容有关。诸如此类
机器:: get('email')
返回机器的集合
数组/集合,执行此操作:Machines :: Pluck('email')
返回strings
之类的集合:如果您解释了阵列,则可以做:
也 可以: ,SideNote,Laravel中的模型名称是按照惯例单数来进行的,因此应该是
Machine
而不是Machines
。I'm not sure what part of your code is triggering that error, but I suspect it has something to do with what
::get('email')
is returning.Machines::get('email')
returns a Collection ofMachines
instances like this:If you want all of the
email
column values in an Array/Collection, do this:Machines::pluck('email')
returns a Collection ofstrings
like this:If you explictly need an array, you can do:
Also, sidenote, Model names in Laravel are by convention singular, so it should be
Machine
instead ofMachines
.