notification generated uuid #48304
-
|
hello, i'm in use of Database notifications with oracle database, i'm deal with views and procedures i need to customize DatabaseNotification class, it still generating an id for every record i need to make database do this not the notification system, i traced the generation of id it is in sendNow function into NotificationSender class it generate notificationId like $notificationId = Str::uuid()->toString(); in line 102 then set the notification id to id in the function sendToNotifiable with this code |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Hey ✋🏻 You can't stop it because it's too deep in the core to override the default behavior.
use App\Listeners\UpdateNotification;
use Illuminate\Notifications\Events\NotificationSent;
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
NotificationSent::class => [
UpdateNotification::class,
],
];
/**
* Handle the event.
*/
public function handle(NotificationSent $event): void
{
$event->notification->update(['id' => Model::getCustomKey()])
}With this approach, when a notification is dispatched by the notification system, the listener will update the |
Beta Was this translation helpful? Give feedback.
-
|
The solution gave by @chuckrincon is almost correct, I tried implementing like mentioned but it didn't work. Instead you need to check for To be honest, I'd prefer that laravel generated namespace App\Listeners;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Events\NotificationSent;
use Illuminate\Support\Str;
class NotificationSentListener implements ShouldQueue
{
public function handle(NotificationSent $event)
{
if ($event->response instanceof Model) {
$event->response->update(['id' => Str::orderedUuid()->toString()]);
}
}
} |
Beta Was this translation helpful? Give feedback.
Hey ✋🏻
You can't stop it because it's too deep in the core to override the default behavior.
Instead, you could listen to the
Illuminate\Notifications\Events\NotificationSentevent and update the notification with your customID.EventServiceProviderUpdateNotificationWit…