Initial commit: Import existing Laravel project

This commit is contained in:
jeremy bayse
2026-06-15 08:12:33 +02:00
parent 7420d1b466
commit 030d76af53
143 changed files with 21885 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Controllers;
use App\Models\Attachment;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Gate;
class AttachmentController extends Controller
{
/**
* Affiche/télécharge de manière sécurisée une pièce jointe.
*/
public function show(Attachment $attachment)
{
// On vérifie si l'utilisateur a le droit de voir la commande liée à cette pièce jointe
$order = $attachment->order;
Gate::authorize('view', $order);
// Si le fichier n'existe pas dans le stockage public
if (!Storage::disk('public')->exists($attachment->file_path)) {
abort(404, 'Fichier non trouvé.');
}
$path = Storage::disk('public')->path($attachment->file_path);
// On renvoie le fichier pour affichage inline (utile pour les PDF/images)
return response()->file($path, [
'Content-Disposition' => 'inline; filename="' . basename($attachment->file_name) . '"'
]);
}
}