@php $faviconPath = (string) setting('site_favicon'); $faviconUrl = filter_var($faviconPath, FILTER_VALIDATE_URL) ? $faviconPath : asset($faviconPath); $faviconPathForType = parse_url($faviconPath, PHP_URL_PATH) ?: $faviconPath; $faviconExtension = strtolower(pathinfo($faviconPathForType, PATHINFO_EXTENSION)); $faviconType = match ($faviconExtension) { 'svg' => 'image/svg+xml', 'png' => 'image/png', 'jpg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', default => 'image/x-icon', }; $relativeFaviconPath = ltrim($faviconPathForType, '/'); $faviconDiskPath = null; if (! filter_var($faviconPath, FILTER_VALIDATE_URL)) { $faviconDiskPath = str_starts_with($relativeFaviconPath, 'storage/') ? storage_path('app/public/'.substr($relativeFaviconPath, 8)) : public_path($relativeFaviconPath); } $faviconVersion = $faviconDiskPath && is_file($faviconDiskPath) ? filemtime($faviconDiskPath) : config('app.version'); $faviconUrlWithVersion = $faviconUrl.(str_contains($faviconUrl, '?') ? '&' : '?').'v='.$faviconVersion; @endphp