Initial commit with contrats and domaines modules

This commit is contained in:
mrKamoo
2026-04-08 18:07:08 +02:00
commit 092a6a0484
191 changed files with 24639 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
<?php
namespace App\Http\Controllers;
use App\Models\Categorie;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
class CategorieController extends Controller
{
public function index(): Response
{
return Inertia::render('Categories/Index', [
'categories' => Categorie::withCount('articles')->orderBy('ordre')->get(),
]);
}
public function store(Request $request): RedirectResponse
{
$this->authorize('create', Categorie::class);
$validated = $request->validate([
'nom' => 'required|string|max:100|unique:categories,nom',
'description' => 'nullable|string',
'couleur' => 'nullable|string|max:7',
'icone' => 'nullable|string|max:50',
'ordre' => 'nullable|integer|min:0',
]);
Categorie::create($validated);
return back()->with('success', 'Catégorie créée.');
}
public function update(Request $request, Categorie $categorie): RedirectResponse
{
$this->authorize('update', Categorie::class);
$validated = $request->validate([
'nom' => 'required|string|max:100|unique:categories,nom,' . $categorie->id,
'description' => 'nullable|string',
'couleur' => 'nullable|string|max:7',
'icone' => 'nullable|string|max:50',
'ordre' => 'nullable|integer|min:0',
'active' => 'boolean',
]);
$categorie->update($validated);
return back()->with('success', 'Catégorie mise à jour.');
}
public function destroy(Categorie $categorie): RedirectResponse
{
$this->authorize('delete', Categorie::class);
$categorie->update(['active' => false]);
return back()->with('success', 'Catégorie désactivée.');
}
}