> For the complete documentation index, see [llms.txt](https://docs.laravel-haystack.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.laravel-haystack.dev/next-up/before-saving-hook.md).

# Before Saving Hook

Sometimes you may wish to modify the Haystack model before it is saved. You can use the `beforeSave` method to modify the Haystack model instance.

```php
<?php

Haystack::build()
    ->addJob(new RecordPodcast)
    ->beforeSave(function (Haystack $haystack) {
         $haystack->options->customOption = true;
     })
    ->dispatch();
```
