Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel-使用变量重定向到细枝页面_Php_Symfony_Redirect_Laravel 5_Twig - Fatal编程技术网

Php Laravel-使用变量重定向到细枝页面

Php 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

我制作了一个邮件函数,用于尝试/捕获情况。它检查邮件模板是否存在,如果不存在,它需要返回重定向/返回到带有messagereturn redirect'dashboard'->带有'status'的页面,邮件不存在

是否可以使用细枝页面使用变量重定向?或者只是我做错了什么

这是我的邮件函数DashboardController.php

 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}}哦,我错过了那一个,如果有效,也接受同样的