dimanche 10 février 2019

Undefined offset: 0 in blade Laravel 5.6

I am trying to fetch data from blade template. I am trying but it does not show me anything. In database table there is a value 10 against u_id. when my code is like

@foreach($school_data as $val)
  <?php 
      $datas2 = \App\criteria::where('u_id', $val->u_id)->get();
      $trck2= $datas2['0']->updated_by_email;
   ?>
@endforeach

it shows Undefined offset: 0 . But when it is a static value

@foreach($school_data as $val)       
 <?php 
      $datas2 = \App\criteria::where('u_id', '10')->get();
      $trck2= $datas2['0']->updated_by_email;
   ?>
@endforeach

then it works properly. How can I fix it?

Thanks in advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire