Skip to content

Commit 601a815

Browse files
committed
Update livewire_alpine_context.md
1 parent 981d6eb commit 601a815

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

.claude/context/livewire_alpine_context.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Livewire Best Practices
44

5-
### Component Structure
5+
### Component Structure using Laravel Volt
66
```php
77
<?php
88

@@ -11,12 +11,15 @@ namespace App\Livewire;
1111
use Livewire\Component;
1212
use Livewire\WithPagination;
1313
use Livewire\Attributes\Validate;
14+
use Livewire\Attributes\Url;
15+
use Livewire\Attributes\Computed;
1416

1517
class CustomerList extends Component
1618
{
1719
use WithPagination;
1820

1921
#[Validate('required|string|min:2')]
22+
#[Url]
2023
public string $search = '';
2124

2225
#[Validate('in:active,inactive,all')]
@@ -36,12 +39,11 @@ class CustomerList extends Component
3639

3740
public function render()
3841
{
39-
return view('livewire.customer-list', [
40-
'customers' => $this->getCustomers(),
41-
]);
42+
return view('livewire.customer-list');
4243
}
4344

44-
private function getCustomers()
45+
#[Computed]
46+
public function customers()
4547
{
4648
return Customer::query()
4749
->when($this->search, fn($query) => $query->search($this->search))

0 commit comments

Comments
 (0)