设置变量输出的样式,以返回控制器方法

时间:2019-07-11 05:48:26

标签: php laravel controller

我将在控制器方法返回中返回付款成功的成功消息。并连接我从请求中接收到的变量以与其一起显示。

如何设置此变量的样式?像使它有点大胆或类似的东西。

我要退货:

return back()->with('success_message', 'Thank you! Your payment has been accepted. This is the link you bought: '. $request->title;

我正在像这样的刀片中显示消息

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

我要设置$return->title的样式。

2 个答案:

答案 0 :(得分:0)

返回一组消息

return back()->with([
    'success_message' => 'Thank you! Your payment has been accepted. This is the link you bought: ',
    'title' => $request->title
]);

,并在您的视图中相应地设置样式

<div class="alert alert-success">
    {{ session()->get('success_message') }}
    <strong>{{ session()->get('title') }}</strong>
</div>

答案 1 :(得分:0)

您应该尝试以下操作:

$parameters = ['success' => 'Thank you! Your payment has been accepted. This is the link you bought: ', 'title' => $request->title];
return redirect()->back()->withInput()->with($parameters);

OR

return redirect()->back()->withInput()->withFlashSuccess($parameters);