Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rutem's avatar
Level 1

Notification displaying multiple times.

I am using Laravel 9 and Filament. I have a Resource class called "ProductResource" for products. The "table" function in the "ProductResource" class displays all the products in the database with predefined actions such as "View, Edit, Delete". I have created a custom action class to add products to a cart. In this custom action class, I redirect the user to another page using the "url" method, but I want to execute a condition before the redirection. Here is a part of the code for the custom action class :

$this->url(function (Product $record) { if ($record->stock == 0) { $this->failure(); return route('filament.resources.products.index'); }else{ return route('filament.pages.product-to-add', ['record' => $record]); } }); $this->failureNotificationTitle(__('Product out of stock'));

The notification "this failure" displays 3 times every time the page is loaded, despite the condition. I don't know why.

0 likes
4 replies
shaungbhone's avatar
$this->url(fn ($record) => $record->stock == 0
    ? $this->failure(__('Product out of stock'))
    : route('filament.pages.product-to-add', ['record' => $record])
);
rutem's avatar
Level 1

@shaungbhone thanks for reply but notifications still keep popping up multiple times.

Please or to participate in this conversation.