Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

melx's avatar
Level 4

How to Display the Unit_id as name in one table

I need the help to display the unit name which id display in one table,

this is the code i have tried in my controller and am still get the the Id instead of Devicename

       $receiveDevice=Issue_to_sale::with('team')
         ->select('unit_id',DB::raw("group_concat(unit_tag_id SEPARATOR ', ') as all_tags"))
            ->where([
               ['team_id',$userId],
               ['ack_status','=',0]
                ])  
                ->groupBy('unit_id')
                ->get();

and my tables

               unit_id            unit_tag_id
                  1                    2
                   1                    3
                    1                     4

device table id Devicename 1 787878887 3 E07126767 2 655666776

0 likes
4 replies
a4ashraf's avatar

@emfinanga

what is your table fields of your

device table id Devicename 1 787878887 3 E07126767 2 655666776

in your database

melx's avatar
Level 4

@a4ashraf table field is id,Devicenumber the seconda table tb2 am just takes id and insert into unit_id or unit_tag_id

Please or to participate in this conversation.