feat: infrastructure assets management with warranty tracking and EAN lookup integration

This commit is contained in:
jeremy bayse
2026-04-09 21:51:43 +02:00
parent 3544c77bd1
commit b28c56c94c
46 changed files with 2961 additions and 414 deletions

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Http\Controllers;
use App\Models\Commune;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
class CommuneController extends Controller
{
public function index(): Response
{
return Inertia::render('Communes/Index', [
'communes' => Commune::withCount('commandes', 'contrats')->get(),
]);
}
public function store(Request $request): RedirectResponse
{
$validated = $request->validate([
'nom' => 'required|string|max:100|unique:communes,nom',
'code_postal' => 'nullable|string|max:10',
]);
Commune::create($validated);
return back()->with('success', 'Commune créée.');
}
public function update(Request $request, Commune $commune): RedirectResponse
{
$validated = $request->validate([
'nom' => 'required|string|max:100|unique:communes,nom,' . $commune->id,
'code_postal' => 'nullable|string|max:10',
]);
$commune->update($validated);
return back()->with('success', 'Commune mise à jour.');
}
public function destroy(Commune $commune): RedirectResponse
{
if ($commune->commandes()->exists() || $commune->contrats()->exists()) {
return back()->with('error', 'Impossible de supprimer une commune liée à des commandes ou des contrats.');
}
$commune->delete();
return back()->with('success', 'Commune supprimée.');
}
}