@@ -637,7 +637,7 @@ <h3 class="text-lg font-semibold mb-3">Creating the Layout</h3>
637637 </div>
638638 <?php endif; ?>
639639
640- <?= section(' content') ?>
640+ <?= $ content ?>
641641 </main>
642642</body>
643643</html></ 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 "> <?php layout('todos'); ?>
650650
651- <?php section('content'); ?>
652651<div class="bg-white rounded-lg shadow p-6">
653652 <h1 class="text-2xl font-bold mb-6">My Todos</h1>
654653
@@ -719,8 +718,7 @@ <h3 class="text-lg font-semibold mb-3 mt-6">Creating the Todos Index View</h3>
719718 <p class="text-gray-500 text-center py-8">No todos yet. Create your first todo above!</p>
720719 <?php endif; ?>
721720 </div>
722- </div>
723- <?php section('content'); ?></ code > </ pre >
721+ </div></ 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 <h2 class="text-xl font-bold mb-4">Interactive Todo List</h2>
862860
863861 <!-- Add Todo Form -->
864- <div class="mb-6">
862+ <form wire:submit="addTodo" class="mb-6">
865863 <div class="flex gap-4 mb-2">
866864 <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 >
872870 <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 >
878876 <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 >
882880 Add
883881 </button>
884882 </div>
885- </div >
883+ </form >
886884
887885 <!-- Todos List -->
888886 <div class="space-y-3">
@@ -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 "> <?= wire_name('todo-list') ?></ 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 "> <?= wire('TodoList') ?></ code > </ pre >
927928 </ section >
928929
929930 <!-- Events -->
0 commit comments