Skip to content

Commit 28ed954

Browse files
committed
updated
1 parent e84082f commit 28ed954

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

tutorial-building-todo-app.html

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ <h3 class="text-lg font-semibold mb-3">Creating the Layout</h3>
637637
&lt;/div&gt;
638638
&lt;?php endif; ?&gt;
639639

640-
&lt;?= section('content') ?&gt;
640+
&lt;?= $content ?&gt;
641641
&lt;/main&gt;
642642
&lt;/body&gt;
643643
&lt;/html&gt;</code></pre>
@@ -648,7 +648,6 @@ <h3 class="text-lg font-semibold mb-3 mt-6">Creating the Todos Index View</h3>
648648
</p>
649649
<pre class="bg-gray-100 p-4 rounded mb-4"><code class="language-php">&lt;?php layout('todos'); ?&gt;
650650

651-
&lt;?php section('content'); ?&gt;
652651
&lt;div class="bg-white rounded-lg shadow p-6"&gt;
653652
&lt;h1 class="text-2xl font-bold mb-6"&gt;My Todos&lt;/h1&gt;
654653

@@ -719,8 +718,7 @@ <h3 class="text-lg font-semibold mb-3 mt-6">Creating the Todos Index View</h3>
719718
&lt;p class="text-gray-500 text-center py-8"&gt;No todos yet. Create your first todo above!&lt;/p&gt;
720719
&lt;?php endif; ?&gt;
721720
&lt;/div&gt;
722-
&lt;/div&gt;
723-
&lt;?php section('content'); ?&gt;</code></pre>
721+
&lt;/div&gt;</code></pre>
724722
</section>
725723

726724
<!-- ForgeWire Components -->
@@ -780,12 +778,12 @@ <h3 class="text-lg font-semibold mb-3">Creating the TodoList Wire Component</h3>
780778
return;
781779
}
782780

783-
$todo = new Todo();
784-
$todo->user_id = $user->id;
785-
$todo->title = $this->newTodoTitle;
786-
$todo->description = $this->newTodoDescription ?: null;
787-
$todo->completed = false;
788-
$todo->save();
781+
$this->repository->create([
782+
'user_id' => $user->id,
783+
'title' => $this->newTodoTitle,
784+
'description' => $this->newTodoDescription ?: null,
785+
'completed' => false,
786+
]);
789787

790788
$this->newTodoTitle = '';
791789
$this->newTodoDescription = '';
@@ -861,28 +859,28 @@ <h3 class="text-lg font-semibold mb-3 mt-6">Creating the Wire Component View</h3
861859
&lt;h2 class="text-xl font-bold mb-4"&gt;Interactive Todo List&lt;/h2&gt;
862860

863861
&lt;!-- Add Todo Form --&gt;
864-
&lt;div class="mb-6"&gt;
862+
&lt;form wire:submit="addTodo" class="mb-6"&gt;
865863
&lt;div class="flex gap-4 mb-2"&gt;
866864
&lt;input
867865
type="text"
868-
wire:model="newTodoTitle"
866+
wire:model.lazy="newTodoTitle"
869867
placeholder="Todo title..."
870868
class="flex-1 px-4 py-2 border border-gray-300 rounded-md"
871869
&gt;
872870
&lt;input
873871
type="text"
874-
wire:model="newTodoDescription"
872+
wire:model.lazy="newTodoDescription"
875873
placeholder="Description (optional)"
876874
class="flex-1 px-4 py-2 border border-gray-300 rounded-md"
877875
&gt;
878876
&lt;button
879-
wire:click="addTodo"
877+
type="submit"
880878
class="px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700"
881879
&gt;
882880
Add
883881
&lt;/button&gt;
884882
&lt;/div&gt;
885-
&lt;/div&gt;
883+
&lt;/form&gt;
886884

887885
&lt;!-- Todos List --&gt;
888886
&lt;div class="space-y-3"&gt;
@@ -921,9 +919,12 @@ <h3 class="text-lg font-semibold mb-3 mt-6">Creating the Wire Component View</h3
921919

922920
<h3 class="text-lg font-semibold mb-3 mt-6">Using the Wire Component</h3>
923921
<p class="text-gray-600 mb-4">
924-
In your view, use the <code class="bg-gray-100 px-2 py-1 rounded">wire()</code> helper to render the component:
922+
In your view, use the <code class="bg-gray-100 px-2 py-1 rounded">wire_name()</code> helper to render the component:
923+
</p>
924+
<pre class="bg-gray-100 p-4 rounded mb-4"><code class="language-php">&lt;?= wire_name('todo-list') ?&gt;</code></pre>
925+
<p class="text-gray-600 mb-4 mt-4">
926+
The <code class="bg-gray-100 px-2 py-1 rounded">wire_name()</code> helper automatically converts kebab-case names (like <code class="bg-gray-100 px-2 py-1 rounded">todo-list</code>) to the corresponding component class (<code class="bg-gray-100 px-2 py-1 rounded">App\Components\Wire\TodoList</code>).
925927
</p>
926-
<pre class="bg-gray-100 p-4 rounded mb-4"><code class="language-php">&lt;?= wire('TodoList') ?&gt;</code></pre>
927928
</section>
928929

929930
<!-- Events -->

0 commit comments

Comments
 (0)