i have found this package: https://github.com/mvanduijker/laravel-transactional-model-events i guess this package wouldn´t exist if laravel would be able to handle this out of the box ;-) anyway... i am still open for suggestions and ideas 😉
need advise: eloquent notifications but inside transactions
hi all,
i really like the concept of sending notifications, when an object gets saved. BUT it seems like, it does not work, when your notification contains data from another table as well. example: someone is buying something, you save the order itself in "order" and the items in "order_item" - so when i send a notification when an order is saved via:
protected static function booted(): void {
static::saved(static function ($order) {
$order->notifyNow(new NewOrderCreated($order));
});
}
and inside my NewOrderCreated i am fetching items from "order_items" i don´t get anything.
i guess because at the moment the notification gets sent, the "order_items" are not yet saved,
because the whole saving of these two tables is happening inside a transaction.
i don´t know if i do something wrong here - but since i am using laravel, i learned: there is ALWAYS a solution for EVERYTHING ;-)))
maybe, in that case, i described, a object-notification is not useful - because of the transaction - may be there exists something, to make this working.
i would be very happy, to get some advice here.
thanks a lot! micha
Please or to participate in this conversation.