TypeError: Carbon\Carbon::rawAddUnit(): Argument #3 ($value) must be of type int|float, string given,
rnooxx999 opened this issue · comments
after updating Laravel to version 11 this problem showing up
TypeError: Carbon\Carbon::rawAddUnit(): Argument #3 ($value) must be of type int|float, string given, called in Documents/Sites/../vendor/nesbot/carbon/src/Carbon/Traits/Units.php on line 356 in file /Documents/Sites/../vendor/nesbot/carbon/src/Carbon/Traits/Units.php on line 455
@rnooxx999 Here is the temporary solution: Link
If you're dealing with the following error message:
Carbon\\Carbon::rawAddUnit(): Argument #3 ($value) must be of type int|float, string given
it's likely because the JWT 'ttl' (time to live) value was passed as a string instead of an integer. I found that this could be fixed by casting the 'ttl' to an integer in the JWT configuration file. Here's what I did to resolve the issue:
// Inside config/jwt.php
'ttl' => (int) env('JWT_TTL', 60), // Cast to int to avoid errors
If you need to change the 'ttl' to a different value, like 4320, be cautious about how you set it in your .env
file. If you simply write JWT_TTL=4320
, there's a risk it might still be interpreted as a string. Instead, it's safer to update the configuration directly:
// Inside config/jwt.php
'ttl' => (int) env('JWT_TTL', 4320), // Ensures 'ttl' is always cast to int
This way, regardless of how the 'ttl' value is specified in the environment file, you can be sure that it will be correctly interpreted as an integer, preventing the type mismatch error.
Hopefully, this helps you avoid similar issues.
JWT_TTL=4320
Thank you it's Work ..