You are not describing very well exactly how these two tables are related. Is the comma-separated data in unit_tag_id referencing the id in tbl 1?
Nov 10, 2020
5
Level 4
Display Data in a blade
I have two table which are related with FK
Tb1 has contain this data
id UnitName
1 7676768
2 6768788
3 5657780
4 6724353
Tb2 has contain this data
unitId Unit_tag_id
2 1,3
4 null
How can i display such a data 1,3 in a blade, assume i have made relation in model of Tb2 that means unitId has belongs to
how my controller will be like and how blade also be like
Level 4
i get the answer
$receiveDevice=Issue_to_sale::with('deviceNumb')->where([
['team_id',$userId],
['ack_status','=',0]
])
//starting here
->leftJoin("devices as devices",\DB::raw("FIND_IN_SET(devices.id,issue_to_sales.unit_tag_id)"),">",\DB::raw("'0'"))
->groupBy('issue_to_sales.unit_id')
->get(['issue_to_sales.*',
\DB::raw("group_concat(devices.Devicenumber SEPARATOR ', ') as name")
]);
Please or to participate in this conversation.