F
Filamentā€¢6mo ago
Jordy

Issue with Summary Range formatting

->formatStateUsing(function ($state) {
return $state / 100;
})
->formatStateUsing(function ($state) {
return $state / 100;
})
wont work because Unsupported operand types: array / int dd state:
array:2 [ā–¼ // ...
0 => 100
1 => 400
]
array:2 [ā–¼ // ...
0 => 100
1 => 400
]
ok, so I do
->formatStateUsing(function ($state) {
return $state[0] / 100 . ' - ' . $state[1] / 100;
})
->formatStateUsing(function ($state) {
return $state[0] / 100 . ' - ' . $state[1] / 100;
})
it just shows 1 and nothing else how do I format this then? (want 1-4)
No description
Solution:
you need to return an array with each number
Jump to solution
19 Replies
undercode
undercodeā€¢6mo ago
return sprintf("%.2f", $state[0] / 100) . ' - ' . sprintf("%.2f", $state[1] / 100);
return sprintf("%.2f", $state[0] / 100) . ' - ' . sprintf("%.2f", $state[1] / 100);
Jordy
JordyOPā€¢6mo ago
same result.. just displays 1's
undercode
undercodeā€¢6mo ago
Sorry, I made a mistake
Jordy
JordyOPā€¢6mo ago
now its 1-. kek.. but theres progress haha
undercode
undercodeā€¢6mo ago
No description
Jordy
JordyOPā€¢6mo ago
yeah the value is correct in my dd aswell, as was return $state[0] / 100 . ' - ' . $state[1] / 100; just doesnt show in the summary dd formatted state:
"1.00 - 4.00" //..
"1.00 - 4.00" //..
shown on summary:
1 - .
1 - .
šŸ’€ how
ConnorHowell
ConnorHowellā€¢6mo ago
Try ->numeric(false) on the summarizer?
Jordy
JordyOPā€¢6mo ago
seems to do nothing
Dan Harrin
Dan Harrinā€¢6mo ago
oh this is a summarizer i didnt know
ConnorHowell
ConnorHowellā€¢6mo ago
Yeah ignore that I was being stupid
Jordy
JordyOPā€¢6mo ago
I feel like this whole problem is me beeing stupid but nothing works šŸ˜‚
Solution
Dan Harrin
Dan Harrinā€¢6mo ago
you need to return an array with each number
Dan Harrin
Dan Harrinā€¢6mo ago
[first, second] we will then spit that out into the view with the dash between
Jordy
JordyOPā€¢6mo ago
ahhhh
ConnorHowell
ConnorHowellā€¢6mo ago
In hindsight that makes a lot of sense considering $state was an array to begin with lol
Dan Harrin
Dan Harrinā€¢6mo ago
:wesmart:
Jordy
JordyOPā€¢6mo ago
yeah this works
->formatStateUsing(function ($state) {
return [
$state[0] / 100,
$state[1] / 100
];
})
->formatStateUsing(function ($state) {
return [
$state[0] / 100,
$state[1] / 100
];
})
Dan Harrin
Dan Harrinā€¢6mo ago
noice
Jordy
JordyOPā€¢6mo ago
thanks now I feel stupid also thank you Dan xD
Want results from more Discord servers?
Add your server