Skip to content

Instantly share code, notes, and snippets.

@mpociot
Created June 30, 2020 10:51
Show Gist options
  • Save mpociot/286de510bfc0a88e697284e90ed1d7da to your computer and use it in GitHub Desktop.
Save mpociot/286de510bfc0a88e697284e90ed1d7da to your computer and use it in GitHub Desktop.
livewire test
<div>
<input wire:model="name" type="text">
<input wire:model="loud" type="checkbox">
<select wire:model="greeting" multiple>
<option>Hello</option>
<option>Goodbye</option>
<option>Adios</option>
</select>
{{ implode(', ', $greeting) }} {{ $name }} @if ($loud) ! @endif
<form action="#" wire:submit.prevent="resetName('Bingo')">
<button>Reset name</button>
</form>
</div>
<?php
use Livewire\Component;
class HelloWorld extends Component
{
public $name = 'Jelly';
public $loud = false;
public $greeting = ['Hello'];
public function resetName($name = 'Chico')
{
$this->name = $name;
}
public function render()
{
return view('hello-world');
}
}
<?php
Route::view('/', 'tinkerwell');
Livewire::component('hello-world', HelloWorld::class);
<html>
<head>
@livewireStyles
</head>
<body>
<h1>Livewire Actions</h1>
<livewire:hello-world />
@livewireScripts
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment