-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Labels
needs more infoMore information is requiredMore information is required
Description
I have Event and Attendee resources which have many to many relationship.
I have an action of Attendee that need to only show up on Event resource detail page.
class Attendee extends Resource
{
public function actions(NovaRequest $request): array
{
return [
(new SendMailByTemplate)->showInline()->canSee(function (NovaRequest $request) {
return $request->viaRelationship();
}),
];
}
}class SendMailByTemplate extends Action
{
public function fields(NovaRequest $request)
{
return [
Select::make(__('Template'), 'template')
->options(...),
Text::make(__('Subject'), 'subject')
->dependsOn(
['template'],
function (Text $field, NovaRequest $request, FormData $formData) use ($mailTemplates) {
if ($formData->template){
// set value
}
}
),
];
}
}This is work fine until I change the select option of the template field which it will call an "action API" which not pass params like viaResource, viaResourceId, viaRelationship which make the canSee return false everytime.
I have temporarily fixed it by change the canSee condition but I don't know if that a right way.
(new SendMailByTemplate)->showInline()->canSee(function (NovaRequest $request) {
return $request->viaRelationship() || !empty($request->resources);
}),- Laravel Version: 11
- Nova Version: 4
Metadata
Metadata
Assignees
Labels
needs more infoMore information is requiredMore information is required