search

Home  >  Q&A  >  body text

Trying to access array offset on null value

<td> {{ $item->salary }} </td>
@if($item['advance']['advance_salary'] == NULL )
    <p>No Advance</p>
@else
    {{ $item['advance']['advance_salary'] }}
@endif
</td>
<td>
    @php
        $amount = $item->salary - $item['advance']['advance_salary'];
    @endphp
    <strong style="color: #fff;"> {{ round($amount) }} </strong>
 </td>

An attempt was made to access the array offset of a value of type null Running these commands

composer update 

php artisan cache:clear <br>
php artisan config:clear<br>
php artisan view:clear

P粉616383625P粉616383625243 days ago431

reply all(1)I'll reply

  • P粉315680565

    P粉3156805652024-03-30 11:45:38

    In some places you expect $item to be an object ($item->salary), in other places you expect $item to be It is an array ($item['advance']['advance_salary']). Fix them first, you may fix errors in the process.

    reply
    0
  • Cancelreply