Livewire

Computed Properties in Livewire v4

February 01, 2026 1 min read 20 views

Computed properties cache expensive calculations.

Usage

use Livewire\Attributes\Computed;
use Livewire\Component;

class PostList extends Component
{
    public string $search = '';
    
    #[Computed]
    public function filteredPosts(): Collection
    {
        return Post::where('title', 'like', "%{$this->search}%")->get();
    }
}

In Blade Template

@foreach($this->filteredPosts as $post)
    
{{ $post->title }}
@endforeach
Share this post:

Related Posts

Comments (0)

Please log in to leave a comment. Log in

No comments yet. Be the first to comment!