Customizing data before saving

On my BD I have:
$table->boolean('is_ready')->default(false);
$table->dateTime('marked_ready_at')->nullable();


On my form, I have:
Forms\Components\Toggle::make('is_ready'),


In my model, I have:
protected $casts = [
        'marked_ready_at' => 'datetime',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
    ];


I want when the toggle is used the 'marked_ready_at' to automatically grab the current date/time.

I have tried the following:
On my Pages/Edit

protected function mutateFormDataBeforeSave(array $data): array
{
    if ($this->record->is_ready) {
        $data['marked_ready_at'] = now();
    }

    return $data;
}


What I/m doing wrong?
Is there a better approach?
Thanks.
Was this page helpful?