© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
4 replies
thyk123

return string instead array

hello i have this code want to show student fullName
Tables\Columns\TextColumn::make('customer_id')
                    ->label('Customer Name')
                    ->formatStateUsing(function ($record, string $state): string{ 
                        switch ($record->customer_type) {
                            case 'student':
                                return Student::where('id', $state)->select(['first_name','last_name'])->get();
                                // dd($data);
                                break
Tables\Columns\TextColumn::make('customer_id')
                    ->label('Customer Name')
                    ->formatStateUsing(function ($record, string $state): string{ 
                        switch ($record->customer_type) {
                            case 'student':
                                return Student::where('id', $state)->select(['first_name','last_name'])->get();
                                // dd($data);
                                break

but i get like this
[{"first_name":"lskdn","last_name":"laksjd"}]
[{"first_name":"lskdn","last_name":"laksjd"}]


how to show pnly first_name and last_name value?
thank you
Solution
try:
return Student::where('id', $state)->select(['first_name','last_name'])->first()->first_name;
return Student::where('id', $state)->select(['first_name','last_name'])->first()->first_name;
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Return value must be of type array, string returned error
FilamentFFilament / ❓┊help
2y ago
Simple repeater data passing in as string instead of array
FilamentFFilament / ❓┊help
2y ago
ToggleButton state return string
FilamentFFilament / ❓┊help
12mo ago