diff options
Diffstat (limited to 'src/Http/Controllers/SvgController.php')
-rw-r--r-- | src/Http/Controllers/SvgController.php | 19 |
1 files changed, 16 insertions, 3 deletions
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', + ] + ); } } |