you can use null coalesce operator ??
no need for @isset
<td>{{ $latestprices->where('product_id',$product->id)->first()->rate_per_kg ?? 0 }}
</td>
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
you can use null coalesce operator ??
no need for @isset
<td>{{ $latestprices->where('product_id',$product->id)->first()->rate_per_kg ?? 0 }}
</td>
really, I felt like you treat snapey as your behind scene coder.... being a developer is so easy with snapey... hahaha....
@siangboon not like that, but when we struct in coding, suddenly it remembers Laracast, when it comes to laracast it remembers @snapey .. thats the reason..
@snapey thank you soo much everything worked fine.. thank you thank you..
you should do me a favor,
kindly paste your answer in this link also, because this also the same question
so that u can get one credit please.
@snapey sorry for disturbing you once again,
small doubt
if i need the overall total amount of the <td>{{ $latestprices->where('product_id',$product->id)->first()->rate_per_kg * $product->openingstock->open_qty }} </td>
the above query is in forloop, so for each product the rate is multiplied with qty and displayed. i need the overall amount at last after the foreach means what should i do?
this means what should i do??
You could just add it in the view?
<td>{{ $latestprices->where('product_id',$product->id)->first()->rate_per_kg * $product->openingstock->open_qty }} </td>
@php $total += $latestprices->where('product_id',$product->id)->first()->rate_per_kg * $product->openingstock->open_qty @endphp
Please or to participate in this conversation.