This is the way to change the code for Nanshao, the beginning of the data with the explored conversion group is not the result, I wrote a method to extract the useful information into a string, and then use explored to convert the string into a group. The method is a bit stupid, but finally solves the problem of Nanshao
$re 1= db::table (' Admin_user ') -Join(' Admin_role_user ', ' admin_user.id ', ' = ', ' admin_role_user.user_id ') ->select (' admin_role_user.role_id ', ' admin_user.username ') ->where (' Admin_user.id ',$user-ID)-get ();//DD ($re 1);//The direct conversion of the array is not the desired result//DD (Explode (', ', $re 1));//This is converting it to a string $str= ""; $cnt= 0; foreach($re 1 as $value) { if($cnt= = 0) { $str=$value-role_id; } Else{ $str=$str.‘,‘.$value-role_id; } $cnt++; }//DD ($STR);//Here Use explode (', ') to turn the string into a group/DD (Explode (', ', $str));
Laravel convert an array into a string and then convert the string to a group