F
Filamentβ€’5mo ago
D2RTECH

how to show the mobile number with country code

I want to combine values of two table columns and show them in the one column. how do i acheive that?
Solution:
Build a virtual column if it's a list view?
TextColumn('full_number')->formatStateUsing(fn($record) => '+' . $record->area_code . $record->phone_number)
TextColumn('full_number')->formatStateUsing(fn($record) => '+' . $record->area_code . $record->phone_number)
...
Jump to solution
4 Replies
D2RTECH
D2RTECHβ€’5mo ago
Basically need to concatenate both of them and prefix them with a + sign kindly help
justlasse
justlasseβ€’5mo ago
How are you storing them in the db or model?
Solution
toeknee
toekneeβ€’5mo ago
Build a virtual column if it's a list view?
TextColumn('full_number')->formatStateUsing(fn($record) => '+' . $record->area_code . $record->phone_number)
TextColumn('full_number')->formatStateUsing(fn($record) => '+' . $record->area_code . $record->phone_number)
D2RTECH
D2RTECHβ€’5mo ago
country code and mobile number are store differently in the db table this worked πŸ™‚