Download the PHP package bastinald/laravel-livewire-model without Composer
On this page you can find all versions of the php package bastinald/laravel-livewire-model. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bastinald/laravel-livewire-model
More information about bastinald/laravel-livewire-model
Files in bastinald/laravel-livewire-model
Package laravel-livewire-model
Short Description Laravel Livewire form data modelling trait.
License MIT
Homepage https://github.com/bastinald/laravel-livewire-model
Informations about the package laravel-livewire-model
Laravel Livewire Model
This package contains a trait which makes Laravel Livewire form data model manipulation a breeze. No more having to create a Livewire component property for every single form input. All form data will be placed inside the $model
property array.
Documentation
- Installation
- Usage
- The WithModel Trait
- Getting Model Data
- Setting Model Data
- Binding Model Data
- Validating Model Data
Installation
Require the package via composer:
Usage
The WithModel Trait
Add the WithModel
trait to your Livewire components:
Getting Model Data
Get all model data as an array:
Get a single value:
Get an array of specific values:
Setting Model Data
Set a single value:
Set values using an array:
Set values using Eloquent model data:
Binding Model Data
Just prepend your wire:model
attribute with model.
:
Validating Model Data
Use the validateModel
method to validate model data:
This method works just like the Livewire validate
method, so you can specify your rules in a separate rules
method if you prefer.