I'm working with Laravel 5.8 and I want to set a session variable at cart.blade.php
Blade, like this:
@php
$conflicted = '';
@endphp
@if($conflicting && ($prd[0]->prd_delivery == 'city_free_delivery' || $prd[0]->prd_delivery == 'country_free_delivery'))
@php Session::put($conflicted , '0') @endphp
<p style="color:red;">
This product has free delivery but it can not be set because of service area conflict of other products
</p>
@endif
@if(!$conflicting && ($prd[0]->prd_delivery == 'country_free_delivery'))
@php Session::put($conflicted , '1') @endphp
<p style="color:red;">
Country Free Delivery
</p>
@endif
@if(!$conflicting && ($prd[0]->prd_delivery == 'city_free_delivery'))
@php Session::put($conflicted , '2') @endphp
<p style="color:red;">
City Free Delivery
</p>
@endif
Now on checkout.blade.php
, I need to check the session value of $conflicted
variable.
So how can I check session value at Blade ?
Because with get
and has
method, I can check the session key name.
You can use session()
helper:
@if (session('conflicted'))
{{ session('conflicted') }}
@endif