2 回答
TA贡献1811条经验 获得超4个赞
您可以通过两种方式执行此操作:
如果您已经设置了会话,则无需将其带到另一个页面,它可以在整个项目中使用。
您可以在 Blade 中这样访问:
<div>
{{ Session::get('package_detail') }}
</div>
您可以在刀片文件中执行以下操作:
@foreach($package_detail as $product)
{{ $product['title'] }}
@endforeach
TA贡献1817条经验 获得超6个赞
public function userLogout()
{
if ($request->session()->has("userLoggedIn")) { // has returns true for userLoggedIn is true and not null
$session = session()->get('userDetails');
$user_id = $session->id;
$user_package = UserPackage::all()->where('user_id','=',$user_id);
foreach($user_package as $package_id) {
$package_detail = Package::where('id','=',$package_id->package_id)->get();
foreach( $package_detail as $package ){
$package_amount[] = $package->price;
$package_tagline[] = $package->tagline;
}
}
session()->flush();
session()->save();
}
$package_detail['package_amount'] = $package_amount;
$package_detail['package_tagline'] = $package_tagline;
$packageCollection = collect($package_detail);
return redirect()->route('frontend-home')->put('package_detail',$packageCollection);
}
像这样访问刀片
@foreach (Session::get('package_detail') as $product_id)
{{$product_id}}
@endforeach
- 2 回答
- 0 关注
- 108 浏览
添加回答
举报