F
Filament2y ago
Gush

How to include the company name dynamically in the message body,

protected function getCreatedNotification(): ?Notification
{
$authenticatedUser = auth()->user();

$adminRole = Role::where('name', 'admin')->first();

$adminRecipients = $adminRole->users()->get();

$recipients = $adminRecipients->union([$authenticatedUser]);

return Notification::make()
->success()
->title('Company registered')
->body('The company ' . $data['name'] . 'has been created successfully.')
->iconColor('success')
->sendToDatabase($recipients);
}
protected function getCreatedNotification(): ?Notification
{
$authenticatedUser = auth()->user();

$adminRole = Role::where('name', 'admin')->first();

$adminRecipients = $adminRole->users()->get();

$recipients = $adminRecipients->union([$authenticatedUser]);

return Notification::make()
->success()
->title('Company registered')
->body('The company ' . $data['name'] . 'has been created successfully.')
->iconColor('success')
->sendToDatabase($recipients);
}
2 Replies
Gush
GushOP2y ago
$name = Company::latest()->pluck('name')->first();

->body('The company ' . $name . 'has been created successfully.')
$name = Company::latest()->pluck('name')->first();

->body('The company ' . $name . 'has been created successfully.')
solution
LeandroFerreira
Not sure if you can access the $this->data['name'] at this point anyway, you can do this $name = Company::latest()->first()->name;
Want results from more Discord servers?
Add your server