Hi, I have a small application where the user can design email templates and publish them. Once published, the email templates can be used in other parts of the application. Therefore I wrote to actions: publish and unpublish Email. This is the code for the publish action:
class PublishMailAction extends Action{ public static function getDefaultName(): ?string { return 'publishEmail'; } protected function setUp(): void { parent::setUp(); $this->icon('fal-check-to-slot'); $this->label(__('mail.labels.publish')); $this->action(static function ($record) { if (MailServiceProvider::publishMailTemplate($record)) { MailNotifications::mailTemplatePublishedSuccess()->send(); return true; } MailNotifications::mailTemplatePublishedFailed()->send(); return false; }); }}
class PublishMailAction extends Action{ public static function getDefaultName(): ?string { return 'publishEmail'; } protected function setUp(): void { parent::setUp(); $this->icon('fal-check-to-slot'); $this->label(__('mail.labels.publish')); $this->action(static function ($record) { if (MailServiceProvider::publishMailTemplate($record)) { MailNotifications::mailTemplatePublishedSuccess()->send(); return true; } MailNotifications::mailTemplatePublishedFailed()->send(); return false; }); }}
The Problem is, that it seems that as soon as I publish an email template, the state is preserved. I published the last email template, and when I click on another entry, the unpublish action is visible and all custom actions refer still to the first published item.