MedicOneSystems/livewire-datatables

Automatically update one column when another is edited

bishwa3141 opened this issue · 0 comments

I have two columns 'rate' and 'total' in my model and my Datatable has the following columns

NumberColumn::name('rate')->label('Rate)')->editable(),
NumberColumn::name('total')->label('Total')->editable(),

I need total to be automatically updated when I update the rate value. Normally I'd achieve that from my Eloquent model like this

---Model.php

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

        self::updating(function($model){ 
            $model->total = $model->rate //(or some similar logic)
}

This works when I do a manual update of the model from my other view but when I use the Livewire datatable, the update doesn't take place on the 'total' column. Any ideas how to work around this?