F
Filamentā€¢4w 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ā€¢4w ago
return sprintf("%.2f", $state[0] / 100) . ' - ' . sprintf("%.2f", $state[1] / 100);
return sprintf("%.2f", $state[0] / 100) . ' - ' . sprintf("%.2f", $state[1] / 100);
Jordy
Jordyā€¢4w ago
same result.. just displays 1's
undercode
undercodeā€¢4w ago
Sorry, I made a mistake
Jordy
Jordyā€¢4w ago
now its 1-. kek.. but theres progress haha
undercode
undercodeā€¢4w ago
No description
Jordy
Jordyā€¢4w 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ā€¢4w ago
Try ->numeric(false) on the summarizer?
Jordy
Jordyā€¢4w ago
seems to do nothing
Dan Harrin
Dan Harrinā€¢4w ago
oh this is a summarizer i didnt know
ConnorHowell
ConnorHowellā€¢4w ago
Yeah ignore that I was being stupid
Jordy
Jordyā€¢4w ago
I feel like this whole problem is me beeing stupid but nothing works šŸ˜‚
Solution
Dan Harrin
Dan Harrinā€¢4w ago
you need to return an array with each number
Dan Harrin
Dan Harrinā€¢4w ago
[first, second] we will then spit that out into the view with the dash between
Jordy
Jordyā€¢4w ago
ahhhh
ConnorHowell
ConnorHowellā€¢4w ago
In hindsight that makes a lot of sense considering $state was an array to begin with lol
Dan Harrin
Dan Harrinā€¢4w ago
:wesmart:
Jordy
Jordyā€¢4w 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ā€¢4w ago
noice
Jordy
Jordyā€¢4w ago
thanks now I feel stupid also thank you Dan xD
Want results from more Discord servers?
Add your server
More Posts