I am rendering view in mail template but in my view I am getting following error when I use dd($row['product_name']);. I get product name but not in following code don't know meaning of this error:
@foreach ($order as $row)
<tr>
<td>{{ $row['product_name'] }}</td>
<td>{{ $row['amount'] }}</td>
<td>{{ $row['quantity'] }}</td>
</tr>
@endforeach
getting error:
Illegal string offset 'product_name'
$order is an object $row->product_name and not an array $row['product_name'].
@foreach ($order as $row)
<tr>
<td>{{ $row->product_name }}</td>
<td>{{ $row->amount }}</td>
<td>{{ $row->quantity }}</td>
</tr>
@endforeach
It might be because of 'product_name' key is not exist in your array element. Before using it, check is that key exist in that array element with isset
@foreach ($order as $row)
<tr>
<td>{{ isset($row['product_name'])?$row['product_name']:'' }}</td>
</tr> @endforeach
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With