I work with laravel spatie permission package and need to show user role for each user in datatables lists. now I add datatables addColumn
method:
$items = Admin::orderBy('id','DESC');
return DataTables::of($items)
->addColumn('role',function(Admin $admin){
foreach($admin->getRoleNames() as $v){
return $v;
}
})
->toJson();
this code work and show role name for each user but If user have a two role name(multiple roles) My code not work and show only first role name. ie: for user test
I have two roles name: moderator
and editor
But i see only moderator.
How to can i show multiple roles name for each user in datatables list?!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire