Aggiungi campi per immagini e diametro del foro nel modello Articolo e nelle relative migrazioni; aggiorna i form e le viste per gestire i nuovi campi
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
@use('Illuminate\Support\Facades\Storage')
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<div class="flex justify-between items-center">
|
||||
@@ -15,11 +16,11 @@
|
||||
</div>
|
||||
</x-slot>
|
||||
|
||||
<div class="py-12">
|
||||
<div class="py-12" x-data="{ modalImg: null }">
|
||||
<div class="max-w-4xl mx-auto sm:px-6 lg:px-8">
|
||||
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<div class="p-6">
|
||||
<form method="POST" action="{{ route('admin.articoli.update', $articolo) }}">
|
||||
<form method="POST" action="{{ route('admin.articoli.update', $articolo) }}" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
@@ -42,6 +43,12 @@
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="hole_diameter" class="block text-sm font-medium text-gray-700">Hole Diameter</label>
|
||||
<input type="text" name="hole_diameter" id="hole_diameter" value="{{ old('hole_diameter', $articolo->hole_diameter) }}"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="diametro" class="block text-sm font-medium text-gray-700">Diametro</label>
|
||||
<input type="text" name="diametro" id="diametro" value="{{ old('diametro', $articolo->diametro) }}"
|
||||
@@ -65,6 +72,26 @@
|
||||
<textarea name="descrizione" id="descrizione" rows="3"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">{{ old('descrizione', $articolo->descrizione) }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="md:col-span-2">
|
||||
<label class="block text-sm font-medium text-gray-700">Immagine Articolo</label>
|
||||
@if ($articolo->immagine_articolo)
|
||||
<div class="mt-2 mb-3 flex items-center gap-4">
|
||||
<img src="{{ Storage::url($articolo->immagine_articolo) }}" alt="Immagine Articolo"
|
||||
class="h-16 w-16 object-cover rounded border cursor-pointer hover:opacity-80 transition-opacity"
|
||||
@click="modalImg = '{{ Storage::url($articolo->immagine_articolo) }}'">
|
||||
<label class="flex items-center gap-2 text-sm text-red-600 cursor-pointer">
|
||||
<input type="checkbox" name="rimuovi_immagine_articolo" value="1" class="rounded border-gray-300">
|
||||
Rimuovi immagine
|
||||
</label>
|
||||
</div>
|
||||
@endif
|
||||
<input type="file" name="immagine_articolo" id="immagine_articolo" accept="image/*"
|
||||
class="mt-1 block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100">
|
||||
@error('immagine_articolo')
|
||||
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -108,12 +135,52 @@
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Immagine Thrust</label>
|
||||
@if ($articolo->immagine_thrust)
|
||||
<div class="mt-2 mb-3 flex items-center gap-4">
|
||||
<img src="{{ Storage::url($articolo->immagine_thrust) }}" alt="Immagine Thrust"
|
||||
class="h-16 w-16 object-cover rounded border cursor-pointer hover:opacity-80 transition-opacity"
|
||||
@click="modalImg = '{{ Storage::url($articolo->immagine_thrust) }}'">
|
||||
<label class="flex items-center gap-2 text-sm text-red-600 cursor-pointer">
|
||||
<input type="checkbox" name="rimuovi_immagine_thrust" value="1" class="rounded border-gray-300">
|
||||
Rimuovi immagine
|
||||
</label>
|
||||
</div>
|
||||
@endif
|
||||
<input type="file" name="immagine_thrust" id="immagine_thrust" accept="image/*"
|
||||
class="mt-1 block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100">
|
||||
@error('immagine_thrust')
|
||||
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="min_torque_a" class="block text-sm font-medium text-gray-700">Min Torque (A)</label>
|
||||
<input type="text" name="min_torque_a" id="min_torque_a" value="{{ old('min_torque_a', $articolo->min_torque_a) }}"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Immagine Tourque</label>
|
||||
@if ($articolo->immagine_tourque)
|
||||
<div class="mt-2 mb-3 flex items-center gap-4">
|
||||
<img src="{{ Storage::url($articolo->immagine_tourque) }}" alt="Immagine Tourque"
|
||||
class="h-16 w-16 object-cover rounded border cursor-pointer hover:opacity-80 transition-opacity"
|
||||
@click="modalImg = '{{ Storage::url($articolo->immagine_tourque) }}'">
|
||||
<label class="flex items-center gap-2 text-sm text-red-600 cursor-pointer">
|
||||
<input type="checkbox" name="rimuovi_immagine_tourque" value="1" class="rounded border-gray-300">
|
||||
Rimuovi immagine
|
||||
</label>
|
||||
</div>
|
||||
@endif
|
||||
<input type="file" name="immagine_tourque" id="immagine_tourque" accept="image/*"
|
||||
class="mt-1 block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100">
|
||||
@error('immagine_tourque')
|
||||
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="quantita_fori" class="block text-sm font-medium text-gray-700">Quantita Fori</label>
|
||||
<input type="number" name="quantita_fori" id="quantita_fori" value="{{ old('quantita_fori', $articolo->quantita_fori) }}" min="0"
|
||||
@@ -134,5 +201,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Image Modal -->
|
||||
<div x-show="modalImg" x-cloak
|
||||
class="fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4"
|
||||
@click="modalImg = null"
|
||||
@keydown.escape.window="modalImg = null">
|
||||
<img :src="modalImg" @click.stop class="max-h-[90vh] max-w-full rounded-lg shadow-2xl">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</x-app-layout>
|
||||
|
||||
@@ -288,7 +288,7 @@
|
||||
}
|
||||
|
||||
function handleFileSelect(file) {
|
||||
if (file && (file.name.endsWith('.xlsx') || file.name.endsWith('.xls'))) {
|
||||
if (file && (file.name.toLowerCase().endsWith('.xlsx') || file.name.toLowerCase().endsWith('.xls'))) {
|
||||
const dataTransfer = new DataTransfer();
|
||||
dataTransfer.items.add(file);
|
||||
fileInput.files = dataTransfer.files;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
@use('Illuminate\Support\Facades\Storage')
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<div class="flex justify-between items-center">
|
||||
@@ -15,7 +16,7 @@
|
||||
</div>
|
||||
</x-slot>
|
||||
|
||||
<div class="py-12">
|
||||
<div class="py-12" x-data="{ modalImg: null }">
|
||||
<div class="max-w-6xl mx-auto sm:px-6 lg:px-8">
|
||||
@if (session('success'))
|
||||
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4">
|
||||
@@ -39,6 +40,10 @@
|
||||
<dt class="text-sm font-medium text-gray-500">Ciclo</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">{{ $articolo->ciclo ?? '-' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Hole Diameter</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">{{ $articolo->hole_diameter ?? '-' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Diametro</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">{{ $articolo->diametro ?? '-' }}</dd>
|
||||
@@ -55,6 +60,16 @@
|
||||
<dt class="text-sm font-medium text-gray-500">Descrizione</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">{{ $articolo->descrizione ?? '-' }}</dd>
|
||||
</div>
|
||||
@if ($articolo->immagine_articolo)
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Immagine Articolo</dt>
|
||||
<dd class="mt-2">
|
||||
<img src="{{ Storage::url($articolo->immagine_articolo) }}" alt="Immagine Articolo"
|
||||
class="h-16 w-16 object-cover rounded border cursor-pointer hover:opacity-80 transition-opacity"
|
||||
@click="modalImg = '{{ Storage::url($articolo->immagine_articolo) }}'">
|
||||
</dd>
|
||||
</div>
|
||||
@endif
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
@@ -88,10 +103,30 @@
|
||||
<dt class="text-sm font-medium text-gray-500">Max Thrust (A)</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">{{ $articolo->max_thrust_a ?? '-' }}</dd>
|
||||
</div>
|
||||
@if ($articolo->immagine_thrust)
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Immagine Thrust</dt>
|
||||
<dd class="mt-2">
|
||||
<img src="{{ Storage::url($articolo->immagine_thrust) }}" alt="Immagine Thrust"
|
||||
class="h-16 w-16 object-cover rounded border cursor-pointer hover:opacity-80 transition-opacity"
|
||||
@click="modalImg = '{{ Storage::url($articolo->immagine_thrust) }}'">
|
||||
</dd>
|
||||
</div>
|
||||
@endif
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Min Torque (A)</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">{{ $articolo->min_torque_a ?? '-' }}</dd>
|
||||
</div>
|
||||
@if ($articolo->immagine_tourque)
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Immagine Tourque</dt>
|
||||
<dd class="mt-2">
|
||||
<img src="{{ Storage::url($articolo->immagine_tourque) }}" alt="Immagine Tourque"
|
||||
class="h-16 w-16 object-cover rounded border cursor-pointer hover:opacity-80 transition-opacity"
|
||||
@click="modalImg = '{{ Storage::url($articolo->immagine_tourque) }}'">
|
||||
</dd>
|
||||
</div>
|
||||
@endif
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Quantita Fori</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">{{ $articolo->quantita_fori ?? '-' }}</dd>
|
||||
@@ -146,5 +181,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Image Modal -->
|
||||
<div x-show="modalImg" x-cloak
|
||||
class="fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4"
|
||||
@click="modalImg = null"
|
||||
@keydown.escape.window="modalImg = null">
|
||||
<img :src="modalImg" @click.stop class="max-h-[90vh] max-w-full rounded-lg shadow-2xl">
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
|
||||
Reference in New Issue
Block a user