Is it possible with Laravel livewire to change a field in the database when leaving the input field?
You can use wire:model.lazy to achieve an action when leaving (loosing focus) on an input field.
wire:model.lazy
<div> <input type="text" class="form-control" wire:model.lazy="billingRate"> </div> class Rate extends Component { public $billingRate; public function updatedBillingRate(){ dd($this->billingRate); // don't forget to use $this to access class property // persist to database here } }
In the above example, whenever billingRate value changes, it will trigger the updatedBillingRate() method.
updatedBillingRate()
Please checkout a similar thred on laracast here (https://laracasts.com/discuss/channels/livewire/livewire-how-to-action-the-value-of-an-input-without-a-button)
2.1m questions
2.1m answers
60 comments
57.0k users