<?php

namespace App\Http\Controllers;

use App\Support\BrandLogoManager;
use Symfony\Component\HttpFoundation\Response;

class BrandAssetController extends Controller
{
    public function appLogo(BrandLogoManager $branding): Response
    {
        $path = $branding->appLogoAbsolutePath();

        abort_unless($path && is_file($path), 404);

        return response()->file($path, [
            'Content-Type' => $branding->mimeTypeForPath($path),
            'Cache-Control' => 'public, max-age=0, must-revalidate',
        ]);
    }

    public function companyLogo(int $company, BrandLogoManager $branding): Response
    {
        $path = $branding->companyLogoAbsolutePath($company);

        abort_unless($path && is_file($path), 404);

        return response()->file($path, [
            'Content-Type' => $branding->mimeTypeForPath($path),
            'Cache-Control' => 'public, max-age=0, must-revalidate',
        ]);
    }
}
