Level 12
Have you found a solution? I'm currently working on and got stuck with the same scenario.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have the following code in a Nova resource:
MorphTo::make('Recipient', 'messageable')
->types([
User::class,
Group::class,
]),
Select::make('Type')
->dependsOn(
['messageable'],
function (Select $field, NovaRequest $request, FormData $formData) {
if ($formData->messageable instanceof \App\Models\User) {
$field->options([
'option 1' => 'Option 1',
'option 2' => 'Option 2',
]);
} elseif ($formData->messageable instanceof \App\Models\Group) {
$field->options([
'option 3' => 'Option 3',
]);
}
}
),
It's not working as $formData->messageable returns a string, the id of the model instance being referenced. How can I get the model type of the messageable being references?
Please or to participate in this conversation.