Parmi Notes Random short any article

ABOUTKEVINYAHYACOM 2

{{ __('Dynamic Database Manager & CRUD Universal') }}

<div class="py-12">
    <div class="max-w-7xl x-auto sm:px-6 lg:px-8 space-y-6" style="margin: 0 auto;">

                   @if($errorMessage || session('error_message'))
            <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
                {{ $errorMessage ?? session('error_message') }}
            </div>
        @endif

        @if(session('success_message'))
            <div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded">
                {{ session('success_message') }}
            </div>
        @endif

                   <div class="p-4 sm:p-8 bg-white shadow sm:rounded-lg">
            <form method="GET" action="{{ route('db.manager') }}" class="space-y-4">
                <div class="grid grid-cols-1 md:grid-cols-5 gap-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700">Host Server</label>
                        <input type="text" name="db_host" value="{{ request('db_host', '127.0.0.1') }}" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm text-sm">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700">Port</label>
                        <input type="text" name="db_port" value="{{ request('db_port', '3306') }}" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm text-sm">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700">Nama DB *</label>
                        <input type="text" name="db_name" value="{{ request('db_name') }}" required class="mt-1 block w-full rounded-md border-gray-300 shadow-sm text-sm">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700">User DB *</label>
                        <input type="text" name="db_user" value="{{ request('db_user') }}" required class="mt-1 block w-full rounded-md border-gray-300 shadow-sm text-sm">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700">Password DB</label>
                        <input type="password" name="db_pass" value="{{ request('db_pass') }}" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm text-sm">
                    </div>
                </div>
                <button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded text-sm">
                    Hubungkan Basis Data
                </button>
            </form>
        </div>

        @if(count($tables) > 0)
            <div class="grid grid-cols-1 md:grid-cols-4 gap-6">
                                   <div class="p-4 bg-white shadow sm:rounded-lg">
                    <h3 class="font-bold text-gray-900 mb-3 border-b pb-2 text-sm">Daftar Tabel ({{ count($tables) }})</h3>
                    <ul class="space-y-1 text-xs">
                        @foreach($tables as $table)
                            <li>
                                <a href="{{ request()->fullUrlWithQuery(['table' => $table]) }}" class="block p-2 rounded {{ $selectedTable == $table ? 'bg-blue-500 text-white font-semibold' : 'text-gray-700 hover:bg-gray-100' }}">
                                    📁 {{ $table }}
                                </a>
                            </li>
                        @endforeach
                    </ul>
                </div>

                                   <div class="md:col-span-3 space-y-6">
                                           <div class="p-4 bg-white shadow sm:rounded-lg">
                        <h3 class="font-bold text-gray-900 mb-2 text-sm">Konsol SQL Murni (Kesaktian CLI)</h3>
                        <form method="POST" action="{{ route('db.execute', request()->query()) }}" class="space-y-2">
                            @csrf
                            <textarea name="sql_query" rows="2" placeholder="Contoh: SELECT * FROM users WHERE id = 1" class="w-full rounded-md border-gray-300 font-mono text-xs">{{ old('sql_query') }}</textarea>
                            <button type="submit" class="bg-gray-800 hover:bg-gray-900 text-white text-xs font-semibold py-1.5 px-3 rounded">
                                Jalankan Kueri
                            </button>
                        </form>

@if(session('query_result'))

{{ print_r(session('query_result'), true) }}
                        @endif
                    </div>

                                           <div class="p-4 bg-white shadow sm:rounded-lg">
                        @if($selectedTable)
                            <h3 class="font-bold text-gray-900 mb-3 text-sm">Data Tabel: <span class="underline text-blue-600">{{ $selectedTable }}</span></h3>
                            <div class="overflow-x-auto max-h-96 border rounded">
                                <table class="min-w-full divide-y divide-gray-200 text-xs">
                                    <thead class="bg-gray-50">
                                        <tr>
                                            @foreach($columns as $col)
                                                <th class="px-3 py-2 text-left font-semibold text-gray-600 border-b uppercase">{{ $col }}</th>
                                            @endforeach
                                        </tr>
                                    </thead>
                                    <tbody class="bg-white divide-y divide-gray-200">
                                        @forelse($rows as $row)
                                            <tr class="hover:bg-gray-50">
                                                @foreach($columns as $col)
                                                    <td class="px-3 py-2 whitespace-nowrap text-gray-700 border-b">{{ $row->$col ?? 'NULL' }}</td>
                                                @endforeach
                                            </tr>
                                        @empty
                                            <tr>
                                                <td colspan="{{ count($columns) }}" class="px-3 py-4 text-center text-gray-400">Tabel Kosong / Tidak ada data.</td>
                                            </tr>
                                        @endforelse
                                    </tbody>
                                </table>
                            </div>
                        @else
                            <div class="text-center py-12 text-gray-400 text-sm">
                                Silakan klik salah satu nama tabel di menu kiri untuk membaca isinya.
                            </div>
                        @endif
                    </div>
                </div>
            </div>
        @endif
    </div>
</div>