Initial scaffold : Laravel 12 + PostgreSQL + auth + domaine métier (étapes 1-5)

- Laravel 12 sur PHP 8.5, Breeze (Blade/Tailwind/Alpine.js)
- Docker Compose dev (PostgreSQL 18 + Redis) et prod (stack complète + nginx)
- Migrations et models : lieux, sections, dépôts, source_types/fields, sources, relevés
  - Colonne JSONB data sur releves avec colonnes générées indexées (nom, prenom, date_evenement)
  - Index GIN pour la recherche fulltext
- Enums : UserRole, SourceStatus (avec transitions), CalendarType, FieldType
- RoleMiddleware (alias `role`) + helpers isAdmin/isSectionManager sur User
- CRUD Lieux (arbre hiérarchique, calcul nom_long en cascade)
- CRUD admin : Sections (+ gestion membres), Dépôts, Types de sources (+ champs dynamiques, drag & drop)
- CRUD Sources : visibilité filtrée par rôle, assignation membres, workflow de statut

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-04 16:16:37 +02:00
commit 7609d35287
172 changed files with 19179 additions and 0 deletions
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
class StoreDepotRequest extends FormRequest
{
public function authorize(): bool { return $this->user()->isAdmin(); }
public function rules(): array
{
return [
'nom' => ['required', 'string', 'max:255'],
'description' => ['nullable', 'string'],
'adresse_postale' => ['nullable', 'string', 'max:500'],
'url' => ['nullable', 'url', 'max:500'],
];
}
}
@@ -0,0 +1,21 @@
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
class StoreSectionRequest extends FormRequest
{
public function authorize(): bool { return $this->user()->isAdmin(); }
public function rules(): array
{
return [
'nom' => ['required', 'string', 'max:255'],
'lieu_id' => ['nullable', 'integer', 'exists:lieux,id'],
'adresse' => ['nullable', 'string', 'max:500'],
'email_contact' => ['nullable', 'email', 'max:255'],
'url' => ['nullable', 'url', 'max:500'],
];
}
}
@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\Admin;
use App\Enums\FieldType;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Enum;
class StoreSourceTypeFieldRequest extends FormRequest
{
public function authorize(): bool { return $this->user()->isAdmin(); }
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:100', 'regex:/^[a-z_]+$/'],
'label' => ['required', 'string', 'max:255'],
'type' => ['required', new Enum(FieldType::class)],
'required' => ['boolean'],
'options' => ['nullable', 'array'],
'options.*'=> ['string', 'max:255'],
];
}
public function messages(): array
{
return [
'name.regex' => 'Le nom technique ne peut contenir que des lettres minuscules et des underscores.',
];
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Requests\Admin;
use App\Enums\FieldType;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Enum;
class StoreSourceTypeRequest extends FormRequest
{
public function authorize(): bool { return $this->user()->isAdmin(); }
public function rules(): array
{
return [
'nom' => ['required', 'string', 'max:255'],
'description' => ['nullable', 'string'],
];
}
}
@@ -0,0 +1,21 @@
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
class UpdateSectionRequest extends FormRequest
{
public function authorize(): bool { return $this->user()->isAdmin(); }
public function rules(): array
{
return [
'nom' => ['required', 'string', 'max:255'],
'lieu_id' => ['nullable', 'integer', 'exists:lieux,id'],
'adresse' => ['nullable', 'string', 'max:500'],
'email_contact' => ['nullable', 'email', 'max:255'],
'url' => ['nullable', 'url', 'max:500'],
];
}
}
+86
View File
@@ -0,0 +1,86 @@
<?php
namespace App\Http\Requests\Auth;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
class LoginRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'email' => ['required', 'string', 'email'],
'password' => ['required', 'string'],
];
}
/**
* Attempt to authenticate the request's credentials.
*
* @throws ValidationException
*/
public function authenticate(): void
{
$this->ensureIsNotRateLimited();
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
RateLimiter::hit($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.failed'),
]);
}
RateLimiter::clear($this->throttleKey());
}
/**
* Ensure the login request is not rate limited.
*
* @throws ValidationException
*/
public function ensureIsNotRateLimited(): void
{
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
return;
}
event(new Lockout($this));
$seconds = RateLimiter::availableIn($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.throttle', [
'seconds' => $seconds,
'minutes' => ceil($seconds / 60),
]),
]);
}
/**
* Get the rate limiting throttle key for the request.
*/
public function throttleKey(): string
{
return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip());
}
}
@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests;
use App\Models\User;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ProfileUpdateRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'email' => [
'required',
'string',
'lowercase',
'email',
'max:255',
Rule::unique(User::class)->ignore($this->user()->id),
],
];
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreLieuRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user()->isAdmin();
}
public function rules(): array
{
return [
'nom' => ['required', 'string', 'max:255'],
'code' => ['nullable', 'string', 'max:20'],
'lieu_parent_id'=> ['nullable', 'integer', 'exists:lieux,id'],
'latitude' => ['nullable', 'numeric', 'between:-90,90'],
'longitude' => ['nullable', 'numeric', 'between:-180,180'],
'note' => ['nullable', 'string'],
];
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreSourceRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user()->isSectionManager();
}
public function rules(): array
{
return [
'nom' => ['required', 'string', 'max:255'],
'description' => ['nullable', 'string'],
'source_type_id' => ['required', 'integer', 'exists:source_types,id'],
'depot_id' => ['nullable', 'integer', 'exists:depots,id'],
'cote' => ['nullable', 'string', 'max:255'],
'auteur' => ['nullable', 'string', 'max:255'],
];
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateLieuRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user()->isAdmin();
}
public function rules(): array
{
$lieuId = $this->route('lieu')->id;
return [
'nom' => ['required', 'string', 'max:255'],
'code' => ['nullable', 'string', 'max:20'],
// Interdit de se choisir soi-même ou un descendant comme parent
'lieu_parent_id'=> ['nullable', 'integer', 'exists:lieux,id', "not_in:{$lieuId}"],
'latitude' => ['nullable', 'numeric', 'between:-90,90'],
'longitude' => ['nullable', 'numeric', 'between:-180,180'],
'note' => ['nullable', 'string'],
];
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateSourceRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user()->isSectionManager();
}
public function rules(): array
{
return [
'nom' => ['required', 'string', 'max:255'],
'description' => ['nullable', 'string'],
'source_type_id' => ['required', 'integer', 'exists:source_types,id'],
'depot_id' => ['nullable', 'integer', 'exists:depots,id'],
'cote' => ['nullable', 'string', 'max:255'],
'auteur' => ['nullable', 'string', 'max:255'],
];
}
}