Skip to content

Instantly share code, notes, and snippets.

@ph7jack
Created July 21, 2021 01:14
Show Gist options
  • Save ph7jack/49365e21b97a469b4ad88e0cf442d5d8 to your computer and use it in GitHub Desktop.
Save ph7jack/49365e21b97a469b4ad88e0cf442d5d8 to your computer and use it in GitHub Desktop.
livewire model
Form.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class Form extends Component
{
public ?string $name = 'pedro';
public function render()
{
return view('livewire.form');
}
}
form.blade.php
<div>
<div class="grid grid-cols-2">
<div>
name: {{ $name }}
<br>
<input class="border" wire:model="name" />
</div>
<livewire:input wire:model="name" />
</div>
</div>
Input.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class Input extends Component
{
public ?string $model = null;
public function render()
{
return view('livewire.input');
}
}
input.blade.php
<div>
model: {{ $model }}
<br>
<input class="border" wire:model="model" />
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment