comparison 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
comparison
equal deleted inserted replaced
25:1a717c7b211f 26:555bfaa500ac
12 <span></span> 12 <span></span>
13 <a href="{{ route('{{ tableName }}.create') }}" class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700"> 13 <a href="{{ route('{{ tableName }}.create') }}" class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">
14 + New {{ ucfirst('{{ modelVariable }}') }} 14 + New {{ ucfirst('{{ modelVariable }}') }}
15 </a> 15 </a>
16 </div> 16 </div>
17 <table class="w-full text-left border-collapse"> 17 <table class="w-full text-left border-collapse table-auto">
18 <thead> 18 <thead>
19 <tr> 19 <tr class="border-b">
20 @foreach($fields as $field) 20 {{ headerInsertPoint }}
21 <th class="border-b p-2">{{ ucfirst($field) }}</th> 21 <th class=" p-2">Actions</th>
22 @endforeach
23 <th class="border-b p-2">Actions</th>
24 </tr> 22 </tr>
25 </thead> 23 </thead>
26 <tbody> 24 <tbody>
27 @forelse ($items as $item) 25 @forelse ($items as $item)
28 <tr> 26 <tr class="border-b">
29 @foreach($fields as $field) 27 {{ valueInsertPoint }}
30 <td class="border-b p-2">{{ $item->$field }}</td> 28 <td class="p-2">
31 @endforeach 29 <div class="flex space-x-2">
32 <td class="border-b p-2 flex space-x-2"> 30 <a href="{{ route('{{ tableName }}.show', $item) }}" class="text-blue-600 hover:underline">View</a>
33 <a href="{{ route('{{ tableName }}.show', $item) }}" class="text-blue-600 hover:underline">View</a>
34 <a href="{{ route('{{ tableName }}.edit', $item) }}" class="text-yellow-600 hover:underline">Edit</a> 31 <a href="{{ route('{{ tableName }}.edit', $item) }}" class="text-yellow-600 hover:underline">Edit</a>
35 <form action="{{ route('{{ tableName }}.destroy', $item) }}" method="POST" class="inline"> 32 <form action="{{ route('{{ tableName }}.destroy', $item) }}" method="POST" class="inline">
36 @csrf 33 @csrf
37 @method('DELETE') 34 @method('DELETE')
38 <button type="submit" class="text-red-600 hover:underline" onclick="return confirm('Delete?')">Delete</button> 35 <button type="submit" class="text-red-600 hover:underline" onclick="return confirm('Delete?')">Delete</button>
39 </form> 36 </form>
37 </div>
40 </td> 38 </td>
41 </tr> 39 </tr>
42 @empty 40 @empty
43 <tr> 41 <tr>
44 <td class="p-2" colspan="{{ count($fields)+1 }}">No {{ tableName }} found.</td> 42 <td class="p-2" colspan="{{ colCount }}">No {{ tableName }} found.</td>
45 </tr> 43 </tr>
46 @endforelse 44 @endforelse
47 </tbody> 45 </tbody>
48 </table> 46 </table>
49 </div> 47 </div>