.webp` or `.png` in `manager.mascot.path` (default: resources/mascot of * the package); a site can give its own set by pointing the path at a folder of its own. A picture that is not there is * answered with a small paw, so the tour works before the pictures do. */ class MascotController { /** What the tour asks for. */ public const NAMES = ['welcome', 'point', 'calm', 'write', 'photos', 'pages', 'undo', 'oops', 'party', 'profile', 'peek']; private const TYPES = ['webp' => 'image/webp', 'png' => 'image/png']; public function __invoke(string $name): BinaryFileResponse|Response { abort_unless(in_array($name, self::NAMES, true), 404); $folder = rtrim((string) (config('manager.mascot.path') ?: __DIR__.'/../../../resources/mascot'), '/'); foreach (self::TYPES as $extension => $type) { if (is_file($path = "$folder/$name.$extension")) { return response()->file($path, ['Content-Type' => $type, 'Cache-Control' => 'public, max-age=86400', 'X-Content-Type-Options' => 'nosniff']); } } return response(self::paw(), 200, ['Content-Type' => 'image/svg+xml', 'Cache-Control' => 'public, max-age=300', 'X-Content-Type-Options' => 'nosniff']); } /** A paw: the stand-in for every picture that is not there yet. */ private static function paw(): string { return '' .'' .'' .''; } }