LMIV-SNACKAUTOMAT/resources/views/admin/products/index.blade.php

132 lines
7.4 KiB
PHP

@extends('layouts.vending')
@section('title', 'Produktkatalog')
@section('content')
<div class="max-w-7xl mx-auto px-4">
<div class="flex justify-between items-center mb-8">
<div>
<h1 class="text-3xl font-bold text-gray-900">Produktkatalog</h1>
<p class="text-gray-600 mt-2">Verwalten Sie Ihre Produkte mit LMIV-Daten</p>
</div>
<a href="{{ route('products.create') }}" class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700">
Neues Produkt
</a>
</div>
@if($products->count() > 0)
<div class="bg-white shadow rounded-lg overflow-hidden">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Produkt
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Preis
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
LMIV-Daten
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Erstellt
</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">
Aktionen
</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@foreach($products as $product)
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<div class="flex-shrink-0 h-12 w-12">
@if($product->image)
<img class="h-12 w-12 rounded object-cover" src="{{ asset('storage/' . $product->image) }}" alt="{{ $product->name }}">
@else
<div class="h-12 w-12 rounded bg-gray-200 flex items-center justify-center">
<span class="text-gray-400 text-xs">Kein Bild</span>
</div>
@endif
</div>
<div class="ml-4">
<div class="text-sm font-medium text-gray-900">
{{ $product->name }}
</div>
@if($product->description)
<div class="text-sm text-gray-500">
{{ Str::limit($product->description, 50) }}
</div>
@endif
</div>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="text-lg font-semibold text-green-600">{{ number_format($product->price, 2) }}</span>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex space-x-1">
@if($product->ingredients)
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
Zutaten
</span>
@endif
@if($product->allergens)
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800">
Allergene
</span>
@endif
@if($product->energy_kcal)
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
Nährwerte
</span>
@endif
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $product->created_at->format('d.m.Y') }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<div class="flex justify-end space-x-2">
<a href="{{ route('products.show', $product) }}" class="text-blue-600 hover:text-blue-900">
Anzeigen
</a>
<a href="{{ route('products.edit', $product) }}" class="text-indigo-600 hover:text-indigo-900">
Bearbeiten
</a>
<form action="{{ route('products.destroy', $product) }}" method="POST" class="inline"
onsubmit="return confirm('Sind Sie sicher, dass Sie dieses Produkt löschen möchten?')">
@csrf
@method('DELETE')
<button type="submit" class="text-red-600 hover:text-red-900">
Löschen
</button>
</form>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="mt-6">
{{ $products->links() }}
</div>
@else
<div class="text-center py-12">
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"/>
</svg>
<h3 class="mt-2 text-sm font-medium text-gray-900">Keine Produkte</h3>
<p class="mt-1 text-sm text-gray-500">Beginnen Sie mit der Erstellung Ihres ersten Produkts.</p>
<div class="mt-6">
<a href="{{ route('products.create') }}" class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700">
Erstes Produkt erstellen
</a>
</div>
</div>
@endif
</div>
@endsection