FilamentF
Filament3y ago
core

How do you manipulate the save/attach methods on filament?

I have a relationsmanager recipe_ingredient I want to convert quantities to metric and imperial on save/edit. here is my attempt but i get nothing:protected $table = 'recipe_ingredient';

public static function boot()
{
parent::boot();

static::creating(function (RecipeIngredient $model) {
Log::info('Creating event fired.');

$model->quantity = $model->quantity * 2;
Log::info('New quantity: '.$model->quantity);
});

static::updating(function ($model) {
Log::info('Updating event fired.');
dd($model);
$model->quantity = $model->quantity * 2;
Log::info('New quantity: '.$model->quantity);
});
}
Was this page helpful?