Home > Net >  Trying to access array offset on value of type bool in laravel 9
Trying to access array offset on value of type bool in laravel 9

Time:12-15

@foreach ($mssg as $mssg)
      <tr>
    <td>{{$mssg["objMessage"]}}</td>
    <td>{{ $mssg["estDateMessage"]  }}  </td>
    <td>
        @if($mssg["active"]==0)
         {{"message non lue"}}
        @else
         {{"messaage lue"}}
        @endif
    </td>
    <td><button><a href="/mssg">lire</a></button></td>
    <td><button>delete</button></td>
  </tr>
  @endforeach

i get Trying to access array offset on value of type bool

i tried to show a list of mssg

CodePudding user response:

Check your foreach code

@foreach ($mssg as $mssg) change to @foreach ($mssg as $m)

then change all entries like {{$mssg["objMessage"]}} to {{$m["objMessage"]}}

You can change the $m to any variable names you want.

CodePudding user response:

Make sure variable $mssg => not null and is_array.

You should dd the $mssg variable in the controller to check what it is, before returning $mssg to the view.

  • Related