mardi 26 mars 2019

i pass an array on blade and want to disply unique value with foreach

i want to pass an array on blade and in my foreach i get unique value if a value already display it don't display

i am beginer in laravel

my blade file code

  @foreach($user as $users)
  <tr>

  <td>@foreach($role as $roles)


,
  @endforeach</td>


  <td>  </td>



</tr>
   @endforeach
</tbody>

my controller

public function roles(Request $request) {

     $user=DB::table('user')->join('model_has_roles', 'id', '=', 'model_has_roles.model_id')->get()->toArray();


     $role=DB::table('roles')->join('model_has_roles', 'id', '=', 'model_has_roles.role_id')->get()->toArray();

    return view('role',compact('user','role'));


}

it display role against any user user did not duplicate



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2CGZ4uv
via IFTTT

Aucun commentaire:

Enregistrer un commentaire