[英]How to pass value in session at the controller to the view blade PHP laravel?
I have one session inside the controller that carried the data from previous page.我在控制器中有一个会话,它携带上一页的数据。 Currently, I want to view the data inside the session at the view.blade.php.
目前,我想在 view.blade.php 中查看会话内的数据。 Or, do I need to create any database query inside the controller?
或者,我是否需要在控制器内创建任何数据库查询?
But, the error that I got is:但是,我得到的错误是:
Undefined variable: user in view.blade.php
Here is the controller.这是控制器。
public function policyDownload(Request $request)
{
$user = \Session::get('plans');
return view('public.policy');
}
Here is the view blade php.这是视图刀片 php。
<div class="row mb-2 mt-2">
<div class="line"></div>
</div>
<div class="row">
<div class="col-md-6">
<b>
<h5><b>TAKAFUL CERTIFICATE</b></h5>
</b><br />
<b>
<h6><b>Person Covered</b></h6>
</b>
{{ strtoupper($user->name) }} ( {{ $user->nric }} ) <br />
{{ strtoupper($user->address) }} <br />
{{ strtoupper($user->address2) }} <br />
{{ strtoupper($user->postcode) }} {{ strtoupper($user->city) }},
{{ strtoupper($user->state) }} <br />
</div>
</div>
Try this尝试这个
$data['user'] = \Session::get('plans');
return view('admin.facts.index', compact('data'));
Your style你的风格
$user = \Session::get('plans');
return view('admin.facts.index', compact('user'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.