with 在 laravel 中不起作用?

with is not woking in laravel?

重定向 url 运行良好,但消息不正常 showing.It 看起来方法无效。

控制器

return redirect('/Patient_Home')->with(['payment_success','Payment has been completed successfully']);

查看

    @if(Session::has('payment_success'))
        <div class="alert alert-success" style="text-align:center">
             {{Session::get('payment_success')}}
        </div>  

@endif

应该是:

return redirect()->route('your patient home route')->with('payment_success','Payment has been completed successfully');

在 blade 视图中,试试这个:

@if ($message = Session::get('payment_success'))
    {{ $message }}
@endif

此外,运行 此命令用于清除缓存: php artisan optimize:clear

此致

您已经创建了一个 RedirectResponse 实例以将数据闪存到单个方法链中的会话。这也适用于在操作后存储状态消息:

return redirect('/Patient_Home')->with(['payment_success','Payment has been completed successfully']);

@if (session('payment_success'))
    <div class="alert alert-success">
        {{ session('payment_success') }}
    </div>
@endif