-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Labels
bugVerified bug by the Nova teamVerified bug by the Nova teamfix incomingA fix is in reviewA fix is in review
Milestone
Description
- Laravel Version: 11.35.0
- Nova Version: 5.0
- PHP Version: 8.3.17
Description:
For models, I used UUID and got this error when running Nova Actions (only on Nova v5):
[2024-12-15 12:36:39] local.ERROR: Laravel\Nova\Http\Requests\ActionRequest::actionableKey(): Return value must be of type int, string returned {"userId":1,"exception":"[object] (TypeError(code: 0): Laravel\\Nova\\Http\\Requests\\ActionRequest::actionableKey(): Return value must be of type int, string returned at /var/www/html/vendor/laravel/nova/src/Http/Requests/ActionRequest.php:223)
[stacktrace]
#0 /var/www/html/vendor/laravel/nova/src/Actions/ActionEvent.php(295): Laravel\\Nova\\Http\\Requests\\ActionRequest->actionableKey()
#1 [internal function]: Laravel\\Nova\\Actions\\ActionEvent::Laravel\\Nova\\Actions\\{closure}()
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(609): array_map()
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(795): Illuminate\\Support\\Arr::map()
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Collection.php(375): Illuminate\\Support\\Collection->map()
#5 /var/www/html/vendor/laravel/nova/src/Actions/ActionEvent.php(291): Illuminate\\Database\\Eloquent\\Collection->map()
#6 /var/www/html/vendor/laravel/nova/src/Actions/DispatchAction.php(192): Laravel\\Nova\\Actions\\ActionEvent::createForModels()
#7 [internal function]: Laravel\\Nova\\Actions\\DispatchAction->Laravel\\Nova\\Actions\\{closure}()
#8 /var/www/html/vendor/laravel/nova/src/Concerns/InteractsWithActionEvent.php(37): call_user_func()
#9 /var/www/html/vendor/laravel/nova/src/Actions/DispatchAction.php(190): Laravel\\Nova\\Nova::usingActionEvent()
#10 /var/www/html/vendor/laravel/nova/src/Actions/Transaction.php(26): Laravel\\Nova\\Actions\\DispatchAction->Laravel\\Nova\\Actions\\{closure}()
#11 /var/www/html/vendor/laravel/nova/src/Actions/DispatchAction.php(189): Laravel\\Nova\\Actions\\Transaction::run()
#12 /var/www/html/vendor/laravel/nova/src/Actions/DispatchAction.php(179): Laravel\\Nova\\Actions\\DispatchAction->dispatchSynchronouslyForCollection()
#13 /var/www/html/vendor/laravel/nova/src/Actions/DispatchAction.php(137): Laravel\\Nova\\Actions\\DispatchAction->forModels()
#14 /var/www/html/vendor/laravel/nova/src/Http/Requests/ActionRequest.php(94): Laravel\\Nova\\Actions\\DispatchAction->Laravel\\Nova\\Actions\\{closure}()
#15 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(259): Laravel\\Nova\\Http\\Requests\\ActionRequest->Laravel\\Nova\\Http\\Requests\\{closure}()
#16 /var/www/html/vendor/laravel/nova/src/Http/Requests/ActionRequest.php(93): Illuminate\\Support\\LazyCollection->each()
#17 /var/www/html/vendor/laravel/nova/src/Actions/DispatchAction.php(129): Laravel\\Nova\\Http\\Requests\\ActionRequest->chunks()
#18 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/helpers.php(520): Laravel\\Nova\\Actions\\DispatchAction->Laravel\\Nova\\Actions\\{closure}()
#19 /var/www/html/vendor/laravel/nova/src/Actions/DispatchAction.php(84): with()
Solution
-public function actionableKey($model): int
+public function actionableKey($model): int | string
{
return $this->isPivotAction()
? $model->{$this->pivotRelation()->getForeignPivotKeyName()}
: $model->getKey();
}Metadata
Metadata
Assignees
Labels
bugVerified bug by the Nova teamVerified bug by the Nova teamfix incomingA fix is in reviewA fix is in review