diff src/Generator/View/stubs/index.stub @ 26:555bfaa500ac codex

Big update for view creation based on the column type.
author Luka Sitas <sitas.luka.97@gmail.com>
date Thu, 15 May 2025 21:50:38 -0400
parents 1a717c7b211f
children 8dd668020310
line wrap: on
line diff
--- a/src/Generator/View/stubs/index.stub	Sun May 11 21:03:51 2025 -0400
+++ b/src/Generator/View/stubs/index.stub	Thu May 15 21:50:38 2025 -0400
@@ -14,34 +14,32 @@
                         + New {{ ucfirst('{{ modelVariable }}') }}
                     </a>
                 </div>
-                <table class="w-full text-left border-collapse">
+                <table class="w-full text-left border-collapse table-auto">
                     <thead>
-                        <tr>
-                            @foreach($fields as $field)
-                                <th class="border-b p-2">{{ ucfirst($field) }}</th>
-                            @endforeach
-                            <th class="border-b p-2">Actions</th>
+                        <tr class="border-b">
+														{{ headerInsertPoint }}
+                            <th class=" p-2">Actions</th>
                         </tr>
                     </thead>
                     <tbody>
                         @forelse ($items as $item)
-                            <tr>
-                                @foreach($fields as $field)
-                                    <td class="border-b p-2">{{ $item->$field }}</td>
-                                @endforeach
-                                <td class="border-b p-2 flex space-x-2">
-                                    <a href="{{ route('{{ tableName }}.show', $item) }}" class="text-blue-600 hover:underline">View</a>
+                            <tr class="border-b">
+																{{ valueInsertPoint }}
+                                <td class="p-2">
+																	<div class="flex space-x-2"> 
+																		<a href="{{ route('{{ tableName }}.show', $item) }}" class="text-blue-600 hover:underline">View</a>
                                     <a href="{{ route('{{ tableName }}.edit', $item) }}" class="text-yellow-600 hover:underline">Edit</a>
                                     <form action="{{ route('{{ tableName }}.destroy', $item) }}" method="POST" class="inline">
                                         @csrf
                                         @method('DELETE')
                                         <button type="submit" class="text-red-600 hover:underline" onclick="return confirm('Delete?')">Delete</button>
                                     </form>
+																	</div>
                                 </td>
                             </tr>
                         @empty
                             <tr>
-                                <td class="p-2" colspan="{{ count($fields)+1 }}">No {{ tableName }} found.</td>
+                                <td class="p-2" colspan="{{ colCount }}">No {{ tableName }} found.</td>
                             </tr>
                         @endforelse
                     </tbody>