-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Labels
bugVerified bug by the Nova teamVerified bug by the Nova team
Description
- Laravel Version: 9.11
- Nova Version: 4.11
- PHP Version: 8.1.6
- Database Driver & Version: mysql 8.0.29
- Operating System and Version: Linux Ubuntu 5.4.0-121-generic
- Browser type and version: Chrome
- Reproduction Repository: N/A
Description:
I have a Nova resource with the following in the fields method:
public function fields(NovaRequest $request)
{
return [
ID::make()->sortable()
->hideFromIndex(),
BelongsTo::make('Alert'),
MorphTo::make('Recipient', 'messageable')
->types([
User::class,
TelegramGroup::class,
]),
Select::make('Type')
->dependsOn(
['messageable'],
function (Select $field, NovaRequest $request, FormData $formData) {
if ($formData->messageable instanceof \App\Models\User) {
$field->options([
'telegram' => 'Telegram',
'email' => 'Email',
'sms' => 'SMS',
]);
} elseif ($formData->messageable instanceof \App\Models\TelegramGroup) {
$field->options([
'telegram' => 'Telegram',
]);
}
}
),
];
}
This is currently not working, as the $formData->messageable just returns a string (with the value of the id of the model being called).
As seen below, it's also the only thing that is contained in the messageable field.
Should this not return the model type of the Polymorphic relationship model also?
Metadata
Metadata
Assignees
Labels
bugVerified bug by the Nova teamVerified bug by the Nova team
