F
Filament3mo ago
mithyy

Performing action on resource view event

Hello, I have a ContactResource. It contains data from the contact form and is saved as is_read=false by default. I want to make is_read=true when this resource is opened with view in the admin panel. How can I do this? In the documentation https://filamentphp.com/docs/3.x/panels/resources/viewing-records I couldn't find anything related to what I want to do on this page, or I didn't understand it.
Solution:
```php public function mount(int|string $record): void { parent::mount($record); $this->record->update(['is_read' => true]);...
Jump to solution
3 Replies
LeandroFerreira
LeandroFerreira3mo ago
you can use the mount method in your ViewPage
Solution
LeandroFerreira
LeandroFerreira3mo ago
public function mount(int|string $record): void
{
parent::mount($record);
$this->record->update(['is_read' => true]);
}
public function mount(int|string $record): void
{
parent::mount($record);
$this->record->update(['is_read' => true]);
}
mithyy
mithyyOP3mo ago
That's what I was looking for. Thank you for your help.
Want results from more Discord servers?
Add your server