feat: L'Ami Fiduciaire V1.0.0 — full codebase with Story 0.1 complete
Initial commit of the L'Ami Fiduciaire SaaS platform built on Laravel 12, Vue 3, Inertia.js 2, and Tailwind CSS 4. Story 0.1 (rename folders to declarations in database) is implemented and code-reviewed: migration, rollback, and 6 Pest tests all passing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
57
app/Http/Controllers/Client/ConfirmController.php
Normal file
57
app/Http/Controllers/Client/ConfirmController.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Client;
|
||||
|
||||
use App\Enums\ActorType;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class ConfirmController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the confirmation page.
|
||||
*/
|
||||
public function show(Request $request, string $token): Response
|
||||
{
|
||||
$invitation = $request->attributes->get('folder_invitation');
|
||||
$folder = $invitation->folder;
|
||||
|
||||
$folder->load(['client']);
|
||||
|
||||
return Inertia::render('client/Confirm', [
|
||||
'folder' => [
|
||||
'id' => $folder->id,
|
||||
'title' => $folder->title,
|
||||
'client_name' => $folder->client->company_name,
|
||||
],
|
||||
'token' => $token,
|
||||
'submitUrl' => route('client.confirm.store', ['token' => $token]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the confirmation (client confirms).
|
||||
*/
|
||||
public function store(Request $request, string $token): RedirectResponse
|
||||
{
|
||||
$invitation = $request->attributes->get('folder_invitation');
|
||||
$folder = $invitation->folder;
|
||||
|
||||
$request->validate([
|
||||
'signature' => ['required', 'string', 'max:255'],
|
||||
]);
|
||||
|
||||
$folder->update([
|
||||
'validated_at' => now(),
|
||||
'confirmed_by_type' => ActorType::Client,
|
||||
'confirmed_by_id' => $folder->client_id,
|
||||
'confirmation_signature' => $request->input('signature'),
|
||||
'status' => \App\Enums\FolderStatus::Validated,
|
||||
]);
|
||||
|
||||
return back()->with('flash', ['type' => 'success', 'message' => 'Validation enregistrée. Merci.']);
|
||||
}
|
||||
}
|
||||
53
app/Http/Controllers/Client/RefuseController.php
Normal file
53
app/Http/Controllers/Client/RefuseController.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Client;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class RefuseController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the refusal page.
|
||||
*/
|
||||
public function show(Request $request, string $token): Response
|
||||
{
|
||||
$invitation = $request->attributes->get('folder_invitation');
|
||||
$folder = $invitation->folder;
|
||||
|
||||
$folder->load(['client']);
|
||||
|
||||
return Inertia::render('client/Refuse', [
|
||||
'folder' => [
|
||||
'id' => $folder->id,
|
||||
'title' => $folder->title,
|
||||
'client_name' => $folder->client->company_name,
|
||||
],
|
||||
'token' => $token,
|
||||
'submitUrl' => route('client.refuse.store', ['token' => $token]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the refusal.
|
||||
*/
|
||||
public function store(Request $request, string $token): RedirectResponse
|
||||
{
|
||||
$invitation = $request->attributes->get('folder_invitation');
|
||||
$folder = $invitation->folder;
|
||||
|
||||
$request->validate([
|
||||
'reason' => ['nullable', 'string', 'max:65535'],
|
||||
]);
|
||||
|
||||
$folder->update([
|
||||
'refused_at' => now(),
|
||||
'refusal_reason' => $request->input('reason'),
|
||||
]);
|
||||
|
||||
return back()->with('flash', ['type' => 'success', 'message' => 'Refus enregistré.']);
|
||||
}
|
||||
}
|
||||
90
app/Http/Controllers/Client/UploadController.php
Normal file
90
app/Http/Controllers/Client/UploadController.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Client;
|
||||
|
||||
use App\Enums\ActorType;
|
||||
use App\Enums\FolderStatus;
|
||||
use App\Enums\MessageType;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\FolderTextMessageMail;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class UploadController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the client upload page.
|
||||
*/
|
||||
public function show(Request $request, string $token): Response
|
||||
{
|
||||
$invitation = $request->attributes->get('folder_invitation');
|
||||
$folder = $invitation->folder;
|
||||
|
||||
$folder->load(['client']);
|
||||
$documents = $folder->getMedia('documents')->map(fn ($m) => [
|
||||
'id' => $m->id,
|
||||
'name' => $m->name,
|
||||
'file_name' => $m->file_name,
|
||||
'size' => $m->human_readable_size,
|
||||
'created_at' => $m->created_at->format('d/m/Y H:i'),
|
||||
])->values()->all();
|
||||
|
||||
return Inertia::render('client/Upload', [
|
||||
'folder' => [
|
||||
'id' => $folder->id,
|
||||
'title' => $folder->title,
|
||||
'client_name' => $folder->client->company_name,
|
||||
],
|
||||
'token' => $token,
|
||||
'documents' => $documents,
|
||||
'uploadUrl' => route('client.upload.store', ['token' => $token]),
|
||||
'csrfToken' => csrf_token(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store uploaded files.
|
||||
*/
|
||||
public function store(Request $request, string $token): RedirectResponse
|
||||
{
|
||||
$invitation = $request->attributes->get('folder_invitation');
|
||||
$folder = $invitation->folder;
|
||||
|
||||
$request->validate([
|
||||
'files' => ['required', 'array', 'min:1'],
|
||||
'files.*' => ['file', 'max:10240'],
|
||||
]);
|
||||
|
||||
$message = $folder->messages()->create([
|
||||
'type' => MessageType::Text,
|
||||
'body' => 'Documents déposés par le client.',
|
||||
'sent_by_type' => ActorType::Client,
|
||||
'sent_by_id' => $folder->client_id,
|
||||
'metadata' => ['invitation_id' => $invitation->id],
|
||||
]);
|
||||
|
||||
foreach ($request->file('files') as $file) {
|
||||
$folder->addMedia($file)
|
||||
->withCustomProperties([
|
||||
'message_id' => $message->id,
|
||||
'uploaded_by_type' => ActorType::Client,
|
||||
'uploaded_by_id' => $folder->client_id,
|
||||
])
|
||||
->toMediaCollection('documents');
|
||||
}
|
||||
|
||||
$folder->update(['status' => FolderStatus::DocumentsReceived]);
|
||||
|
||||
$recipient = $folder->assignee ?? $folder->creator;
|
||||
if ($recipient?->email) {
|
||||
Mail::to($recipient->email)->send(
|
||||
new FolderTextMessageMail($folder, 'Le client a déposé des documents.', null)
|
||||
);
|
||||
}
|
||||
|
||||
return back()->with('flash', ['type' => 'success', 'message' => 'Documents envoyés avec succès.']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user