151 lines
8.1 KiB
PHP
151 lines
8.1 KiB
PHP
@extends('layouts.vending')
|
|
|
|
@section('title', 'Slot bearbeiten')
|
|
|
|
@section('content')
|
|
<div class="max-w-4xl mx-auto px-4">
|
|
<div class="mb-8">
|
|
<div class="flex items-center space-x-4 mb-4">
|
|
<a href="{{ route('slots.index') }}" class="text-blue-600 hover:text-blue-800">
|
|
← Zurück zur Übersicht
|
|
</a>
|
|
</div>
|
|
<h1 class="text-3xl font-bold text-gray-900">Slot {{ $slot->slot_number }} bearbeiten</h1>
|
|
<p class="text-gray-600 mt-2">{{ $slot->vendingMachine->name }} - Slot-Konfiguration bearbeiten</p>
|
|
</div>
|
|
|
|
<form action="{{ route('slots.update', $slot) }}" method="POST" class="space-y-8">
|
|
@csrf
|
|
@method('PUT')
|
|
|
|
<!-- Grundinformationen -->
|
|
<div class="bg-white shadow rounded-lg p-6">
|
|
<h2 class="text-xl font-semibold text-gray-900 mb-6 border-b border-gray-200 pb-2">
|
|
Slot-Konfiguration
|
|
</h2>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
<div>
|
|
<label for="vending_machine_id" class="block text-sm font-medium text-gray-700 mb-2">
|
|
Automat *
|
|
</label>
|
|
<select id="vending_machine_id" name="vending_machine_id" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-purple-500 @error('vending_machine_id') border-red-500 @enderror">
|
|
<option value="">Automat auswählen</option>
|
|
@foreach($vendingMachines as $machine)
|
|
<option value="{{ $machine->id }}" {{ old('vending_machine_id', $slot->vending_machine_id) == $machine->id ? 'selected' : '' }}>
|
|
{{ $machine->name }} ({{ $machine->location }})
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
@error('vending_machine_id')
|
|
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
|
|
@enderror
|
|
</div>
|
|
|
|
<div>
|
|
<label for="slot_number" class="block text-sm font-medium text-gray-700 mb-2">
|
|
Slot-Nummer *
|
|
</label>
|
|
<input type="text" id="slot_number" name="slot_number" value="{{ old('slot_number', $slot->slot_number) }}" required
|
|
placeholder="z.B. 10, 11, A1, B2"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-purple-500 @error('slot_number') border-red-500 @enderror">
|
|
@error('slot_number')
|
|
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
|
|
@enderror
|
|
<p class="text-xs text-gray-500 mt-1">Eindeutige Nummer für diesen Slot im Automaten</p>
|
|
</div>
|
|
|
|
<div>
|
|
<label for="position" class="block text-sm font-medium text-gray-700 mb-2">
|
|
Position
|
|
</label>
|
|
<input type="text" id="position" name="position" value="{{ old('position', $slot->position) }}"
|
|
placeholder="z.B. Reihe 2, Spalte 1 oder Oben Links"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-purple-500 @error('position') border-red-500 @enderror">
|
|
@error('position')
|
|
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
|
|
@enderror
|
|
<p class="text-xs text-gray-500 mt-1">Beschreibung der Position im Automaten (maximal 100 Zeichen)</p>
|
|
</div>
|
|
|
|
<div>
|
|
<label for="capacity" class="block text-sm font-medium text-gray-700 mb-2">
|
|
Kapazität *
|
|
</label>
|
|
<input type="number" id="capacity" name="capacity" value="{{ old('capacity', $slot->capacity) }}" min="1" max="50" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-purple-500 @error('capacity') border-red-500 @enderror">
|
|
@error('capacity')
|
|
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
|
|
@enderror
|
|
<p class="text-xs text-gray-500 mt-1">Maximale Anzahl Produkte in diesem Slot (1-50)</p>
|
|
</div>
|
|
|
|
<div class="md:col-span-2">
|
|
<label class="flex items-center">
|
|
<input type="checkbox" name="is_active" id="is_active" value="1"
|
|
class="h-4 w-4 text-purple-600 focus:ring-purple-500 border-gray-300 rounded"
|
|
{{ old('is_active', $slot->is_active) ? 'checked' : '' }}>
|
|
<span class="ml-2 text-sm text-gray-700">Slot ist aktiv</span>
|
|
</label>
|
|
<p class="text-xs text-gray-500 mt-1">Nur aktive Slots können Produkte enthalten</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Aktuelle Produkt-Zuordnung -->
|
|
@if($slot->products->count() > 0)
|
|
<div class="bg-white shadow rounded-lg p-6">
|
|
<h2 class="text-xl font-semibold text-gray-900 mb-6 border-b border-gray-200 pb-2">
|
|
Aktuelle Produkt-Zuordnung
|
|
</h2>
|
|
|
|
@foreach($slot->products as $product)
|
|
<div class="flex items-center justify-between p-4 bg-blue-50 border border-blue-200 rounded-lg">
|
|
<div class="flex items-center">
|
|
@if($product->image)
|
|
<img class="h-12 w-12 rounded object-cover mr-4" src="{{ asset('storage/' . $product->image) }}" alt="{{ $product->name }}">
|
|
@else
|
|
<div class="h-12 w-12 rounded bg-gray-200 flex items-center justify-center mr-4">
|
|
<span class="text-gray-400 text-xs">?</span>
|
|
</div>
|
|
@endif
|
|
<div>
|
|
<h3 class="font-semibold text-blue-900">{{ $product->name }}</h3>
|
|
<p class="text-blue-700 text-sm">
|
|
Bestand: {{ $product->pivot->quantity ?? 0 }} Stück |
|
|
Preis: {{ number_format($product->pivot->current_price ?? $product->price, 2) }}€
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div class="flex space-x-2">
|
|
<a href="{{ route('slots.show', $slot) }}" class="text-blue-600 hover:text-blue-900 text-sm">
|
|
Bestand verwalten
|
|
</a>
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
@endif
|
|
|
|
<!-- Aktionsbuttons -->
|
|
<div class="flex justify-between items-center bg-gray-50 px-6 py-4 rounded-lg">
|
|
<a href="{{ route('slots.index') }}"
|
|
class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
|
|
Abbrechen
|
|
</a>
|
|
|
|
<div class="flex space-x-3">
|
|
<a href="{{ route('slots.show', $slot) }}"
|
|
class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
|
|
Details ansehen
|
|
</a>
|
|
<button type="submit"
|
|
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-purple-600 hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500">
|
|
Änderungen speichern
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
@endsection |