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
2 Replies
Solution
Lara Zeus
Lara Zeus7mo ago
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;
thyk123
thyk123OP7mo ago
Thank you Lara Zeus admin!
Want results from more Discord servers?
Add your server