view 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 source

<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            All {{ Str::plural(ucfirst('{{ modelVariable }}')) }}
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg p-6">
                <div class="flex items-center justify-between mb-4">
                    <span></span>
                    <a href="{{ route('{{ tableName }}.create') }}" class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">
                        + New {{ ucfirst('{{ modelVariable }}') }}
                    </a>
                </div>
                <table class="w-full text-left border-collapse table-auto">
                    <thead>
                        <tr class="border-b">
														{{ headerInsertPoint }}
                            <th class=" p-2">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        @forelse ($items as $item)
                            <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="{{ colCount }}">No {{ tableName }} found.</td>
                            </tr>
                        @endforelse
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</x-app-layout>