【发布时间】:2017-09-10 16:14:38
【问题描述】:
自从有一天我想访问未序列化的列时,我的视图出现了异常。这真的很奇怪,因为在某些页面中它正在工作,而在另一些页面中我得到一个错误
希望有人可以帮助我.. 我不知道为什么有时它会起作用,有时却不起作用。我还测试了 base64_encode() 和 base64_decode() 但我现在从我的不同记录中得到所有视图的错误
反序列化错误偏移
这里是我创建新订单时的控制器
$order = new Order();
$order->cart = serialize($cart);
...
$order->save();
当我反序列化时,现在是我的控制器
public function show($id)
{
$order = Order::findOrFail($id);
$order->cart = unserialize($order->cart);
$order->cart->totalPrice;
$prix_total = $order->cart->totalPrice;
$structure_id = $order->structure_id;
$structure = Structure::where('id' , '=' , $structure_id)->first();
$federation = Structure::where('id' , '1')->first();
return view('cotisation_structure/show' , compact('prix_total', 'order' , 'structure' , 'federation'));
}
现在我的视图显示我的“购物车”列中的记录:
@foreach($order->cart->items as $item)
<tr>
@if(Auth::user()->isFederation())
<td><input type="checkbox" name="checkbox[]" value="{{$item['item']->id}}"></td>
@endif
<td><a href="{!! route('licencie.show', $item['item']->id) !!}">{{$item['item']->num_licence}}</a></td>
<th>{{$item['item']->lb_nom}}</th>
<th>{{$item['item']->lb_prenom}}</th>
<th>{{$item['item']->structure->nom_structure}}</th>
<td>
@if($item['item']->lb_tricolore != null)
{{$item['item']->lb_activite_tricolore}} - {{$item['item']->lb_tricolore}}
@else
{{$item['item']->activite_licencie->lb_activite}}
@endif
</td>
<th>{{$item['item']->saison->lb_saison}}</th>
<th>{{$order->payment_method}}</th>
<th>{{$item['price']}} € </th>
<td>{{Carbon\Carbon::parse($order->date_achat)->format('d/m/Y')}}</td>
</tr>
@endforeach
【问题讨论】:
标签: laravel