From 2cc8c1a8ea904ec2de857ede865a7bccc0000de4 Mon Sep 17 00:00:00 2001 From: Sam Light Date: Sat, 15 Jun 2024 23:03:44 +0100 Subject: Implemented everything --- src/Http/Controllers/SvgController.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/Http') diff --git a/src/Http/Controllers/SvgController.php b/src/Http/Controllers/SvgController.php index 5296024..9e9c550 100644 --- a/src/Http/Controllers/SvgController.php +++ b/src/Http/Controllers/SvgController.php @@ -4,14 +4,27 @@ namespace Lightscale\LaralightSvg\Http\Controllers; use Lightscale\LaralightSvg\SvgService; -use Illuminate\Http\Controller; +use Illuminate\Routing\Controller; +use Illuminate\Http\Request; class SvgController extends Controller { - public function serveSvg(SvgService $svg, string $collection) + public function serveSvg(SvgService $svg, Request $request, string $collection) { - \Log::debug($collection); + $collection = $svg->getCollection($collection); + if ($collection === null) abort(404); + + $svgContent = $collection->getSvg(); + if ($svgContent === null) abort(404); + + return response( + $svgContent, + 200, + [ + 'Content-Type' => 'image/svg+xml', + ] + ); } } -- cgit v1.2.3