Php Laravel-使用变量重定向到细枝页面
我制作了一个邮件函数,用于尝试/捕获情况。它检查邮件模板是否存在,如果不存在,它需要返回重定向/返回到带有messagereturn redirect'dashboard'->带有'status'的页面,邮件不存在 是否可以使用细枝页面使用变量重定向?或者只是我做错了什么 这是我的邮件函数DashboardController.phpPhp Laravel-使用变量重定向到细枝页面,php,symfony,redirect,laravel-5,twig,Php,Symfony,Redirect,Laravel 5,Twig,我制作了一个邮件函数,用于尝试/捕获情况。它检查邮件模板是否存在,如果不存在,它需要返回重定向/返回到带有messagereturn redirect'dashboard'->带有'status'的页面,邮件不存在 是否可以使用细枝页面使用变量重定向?或者只是我做错了什么 这是我的邮件函数DashboardController.php public function MailContact($date_id, $contact_id) { try { $cont
public function MailContact($date_id, $contact_id)
{
try
{
$contact = Contact::find($contact_id);
$date = Date::find($date_id);
$mail = Mails::where('datetype_id', $date->datetype_id)->first();
$html = $mail->html;
Mail::to($contact->email)->send(new Anniversary($html));
return redirect('dashboard');
}
catch(\Exception $ex )
{
return redirect('dashboard')->with("Mail doesn't exists");
}
}
这是twig页面“dashboard.twig”
<div class="box-body no-padding" style="width: 100%; padding-top:20px;">
<ul class="telephoneKingList" style=" display: inline-block;
width: 100%;">
{% for dates in datestodayUser %}
{% if dates is not empty %}
<li data-id="{{ dates.id }}">
{{ dates.contact.fullname }}, {{ dates.contact.relation.company }} <br>
{{ dates.description }}<br>
{# Place where Error needs to be #}
<a role="button" id="edit-button" href="/dashboard/mail/{{ dates.id }}/{{ dates.contact.id }}" class="btn btn-primary btn-sm"><i class="fa fa-envelope"></i></a>
</li>
<hr>
{% endif %}
{% else %}
<li>
Geen data beschikbaar.
</li>
{% endfor %}
</ul>
你能行
return redirect('dashboard')->with(['message'=>"Mail doesn't exists"]);
然后在你的小树枝上
{{message}}将为您提供消息使用
redirect('dashboard')->withErrors(["Mail doesn't exists"])
在你的小枝中,你需要使用
{{ errors.first() }}
Laravel有一个现成的中间件,名为ShareErrorsFromSession,它与所有视图共享会话错误 结帐:有效,谢谢。{{$message}}应该是{{{message}}哦,我错过了那一个,如果有效,也接受同样的