feat: complete Epic 0 — foundation migration & infrastructure setup

Stories 0.2-0.5: rename folders→declarations (backend+frontend), configure
Redis for cache/queue/sessions, add foundation database migrations
(permissions, archived_at), replace DeclarationStatus enum with architecture
lifecycle values, create DeclarationObserver for status transition validation
and auto-archive, fix controller status transitions to respect observer rules.

93 tests pass (240 assertions).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 18:25:32 +00:00
parent d380df4074
commit fd43a6f429
105 changed files with 3899 additions and 1558 deletions

View File

@@ -2,8 +2,8 @@
namespace App\Http\Controllers;
use App\Enums\FolderStatus;
use App\Models\Folder;
use App\Enums\DeclarationStatus;
use App\Models\Declaration;
use App\Models\Workspace;
use Illuminate\Http\Request;
use Inertia\Inertia;
@@ -12,7 +12,7 @@ use Inertia\Response;
class DashboardController extends Controller
{
/**
* Display the dashboard with assigned folders and notifications.
* Display the dashboard with assigned declarations and notifications.
*/
public function __invoke(Request $request): Response
{
@@ -20,18 +20,18 @@ class DashboardController extends Controller
$workspaceId = $request->session()->get('current_workspace_id');
$workspace = $workspaceId ? Workspace::query()->find($workspaceId) : null;
$assignedFolders = [];
$assignedDeclarations = [];
$notifications = [];
if ($workspace && $user) {
$assignedFolders = $workspace->folders()
$assignedDeclarations = $workspace->declarations()
->where('assigned_to', $user->id)
->whereNotIn('status', [FolderStatus::Closed, FolderStatus::Cancelled])
->whereNotIn('status', [DeclarationStatus::Ferme])
->with('client:id,company_name')
->orderByRaw('CASE WHEN due_date IS NULL THEN 1 ELSE 0 END, due_date ASC')
->limit(50)
->get()
->map(fn (Folder $f) => [
->map(fn (Declaration $f) => [
'id' => $f->id,
'title' => $f->title,
'type' => $f->type->value,
@@ -39,71 +39,71 @@ class DashboardController extends Controller
'status' => $f->status->value,
'due_date' => $f->due_date?->format('Y-m-d'),
'priority' => $f->priority?->value,
'showUrl' => route('folders.show', $f),
'showUrl' => route('declarations.show', $f),
])
->all();
$overdue = $workspace->folders()
$overdue = $workspace->declarations()
->where('assigned_to', $user->id)
->where('due_date', '<', now()->startOfDay())
->whereNotIn('status', [FolderStatus::Closed, FolderStatus::Cancelled])
->whereNotIn('status', [DeclarationStatus::Ferme])
->with('client:id,company_name')
->orderBy('due_date')
->limit(10)
->get()
->map(fn (Folder $f) => [
->map(fn (Declaration $f) => [
'id' => $f->id,
'title' => $f->title,
'client_name' => $f->client->company_name,
'due_date' => $f->due_date?->format('Y-m-d'),
'showUrl' => route('folders.show', $f),
'showUrl' => route('declarations.show', $f),
])
->all();
$dueSoon = $workspace->folders()
$dueSoon = $workspace->declarations()
->where('assigned_to', $user->id)
->whereBetween('due_date', [now()->startOfDay(), now()->addDays(7)->endOfDay()])
->whereNotIn('status', [FolderStatus::Closed, FolderStatus::Cancelled])
->whereNotIn('status', [DeclarationStatus::Ferme])
->with('client:id,company_name')
->orderBy('due_date')
->limit(10)
->get()
->map(fn (Folder $f) => [
->map(fn (Declaration $f) => [
'id' => $f->id,
'title' => $f->title,
'client_name' => $f->client->company_name,
'due_date' => $f->due_date?->format('Y-m-d'),
'showUrl' => route('folders.show', $f),
'showUrl' => route('declarations.show', $f),
])
->all();
$documentsReceived = $workspace->folders()
$documentsReceived = $workspace->declarations()
->where('assigned_to', $user->id)
->where('status', FolderStatus::DocumentsReceived)
->where('status', DeclarationStatus::EnCours)
->with('client:id,company_name')
->orderBy('updated_at', 'desc')
->limit(10)
->get()
->map(fn (Folder $f) => [
->map(fn (Declaration $f) => [
'id' => $f->id,
'title' => $f->title,
'client_name' => $f->client->company_name,
'showUrl' => route('folders.show', $f),
'showUrl' => route('declarations.show', $f),
])
->all();
$awaitingValidation = $workspace->folders()
$awaitingValidation = $workspace->declarations()
->where('assigned_to', $user->id)
->where('status', FolderStatus::WaitingClientValidation)
->where('status', DeclarationStatus::EnAttenteClient)
->with('client:id,company_name')
->orderBy('confirmation_requested_at', 'desc')
->limit(10)
->get()
->map(fn (Folder $f) => [
->map(fn (Declaration $f) => [
'id' => $f->id,
'title' => $f->title,
'client_name' => $f->client->company_name,
'showUrl' => route('folders.show', $f),
'showUrl' => route('declarations.show', $f),
])
->all();
@@ -116,10 +116,10 @@ class DashboardController extends Controller
}
return Inertia::render('Dashboard', [
'assignedFolders' => $assignedFolders,
'assignedDeclarations' => $assignedDeclarations,
'notifications' => $notifications,
'workspaceName' => $workspace?->name ?? null,
'foldersUrl' => $workspace ? route('folders.index') : null,
'declarationsUrl' => $workspace ? route('declarations.index') : null,
'clientsUrl' => $workspace ? route('clients.index') : null,
]);
}