Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Livewire

Building a Todo List with Livewire v4

Create a complete todo application.

1 February 20261 min readLivewireاقرأ بالعربية

On this page

  1. Component

Build a full-featured todo list.

Component

php
class TodoList extends Component
{
    public string $newTodo = '';
    public array $todos = [];
    
    public function add(): void
    {
        $this->todos[] = ['id' => uniqid(), 'text' => $this->newTodo, 'done' => false];
        $this->newTodo = '';
    }
    
    public function toggle(string $id): void
    {
        foreach ($this->todos as &$t) {
            if ($t['id'] === $id) $t['done'] = !$t['done'];
        }
    }
}
All articles

Keep reading

  • Authorization in Livewire v4 Components1 February 20261 min read
  • Blaze Pre-Compiler: Massive Performance Gains in Livewire v41 February 20261 min read
  • Building a Bookmark Feature with Livewire v41 February 20261 min read