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
+63
View File
@@ -0,0 +1,63 @@
<?php
namespace App\Models;
use App\Enums\UserRole;
use Database\Factories\UserFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
/** @use HasFactory<UserFactory> */
use HasFactory, Notifiable;
protected $fillable = ['name', 'email', 'password', 'role'];
protected $hidden = ['password', 'remember_token'];
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'role' => UserRole::class,
];
}
public function isAdmin(): bool
{
return $this->role === UserRole::Admin;
}
public function isSectionManager(): bool
{
return $this->role === UserRole::SectionManager || $this->isAdmin();
}
public function sections(): BelongsToMany
{
return $this->belongsToMany(Section::class, 'section_user')
->withPivot('role_in_section');
}
public function sourcesAssignees(): BelongsToMany
{
return $this->belongsToMany(Source::class, 'source_user');
}
public function isMemberOfSection(Section $section): bool
{
return $this->sections()->where('section_id', $section->id)->exists();
}
public function isManagerOfSection(Section $section): bool
{
return $this->isAdmin() || $this->sections()
->where('section_id', $section->id)
->wherePivot('role_in_section', 'section_manager')
->exists();
}
}