How to disable model observers during creating in Filament?

Hi everyone, In Filament, I have a model with observers attached. During the creating process, I want to temporarily mute/disable those observers so they don’t run. For example, when a record is created through a Filament form, I’d like the creating observer on the model not to execute. My question is: What’s the best approach to achieve this? Is there a recommended way in Filament (or Laravel in general) to temporarily disable observers for a specific action? Thanks!
Solution:
I think you can customize the creation process and use createQuietly($data) ```php protected function handleRecordCreation(array $data): Model {...
Eloquent: Getting Started - Laravel 12.x - The PHP Framework For We...
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Jump to solution
1 Reply
Solution
LeandroFerreira
LeandroFerreira2mo ago
I think you can customize the creation process and use createQuietly($data)
protected function handleRecordCreation(array $data): Model
{
return static::getModel()::createQuietly($data);
}
protected function handleRecordCreation(array $data): Model
{
return static::getModel()::createQuietly($data);
}
Eloquent: Getting Started - Laravel 12.x - The PHP Framework For We...
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.

Did you find this page helpful?