Commit 6f356f13 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fixedimage

parent 50171370
......@@ -45,13 +45,15 @@ RUN mkdir -p \
/var/www/html/storage/uploads/photos \
/var/www/html/storage/uploads/forms \
/var/www/html/storage/cache \
/var/www/html/storage/sessions
/var/www/html/storage/sessions \
/var/www/html/public/assets/uploads/branding
# ── Permissions ──
RUN chown -R www-data:www-data /var/www/html/storage \
&& chmod -R 775 /var/www/html/storage \
&& chown -R www-data:www-data /var/www/html/public \
&& chmod -R 755 /var/www/html/public
&& chmod -R 755 /var/www/html/public \
&& chmod -R 775 /var/www/html/public/assets/uploads
# ── Environment defaults (overridden by CapRover env vars) ──
ENV APP_URL=http://localhost
......
......@@ -61,8 +61,8 @@ class BrandingController extends Controller
if ($ext === 'svg') $ext = 'svg';
$storedFilename = 'logo_' . date('Ymd_His') . '_' . bin2hex(random_bytes(4)) . '.' . $ext;
// Ensure upload directory exists
$uploadDir = App::getInstance()->basePath() . '/storage/uploads/branding/';
// Ensure upload directory exists (inside public/ so Apache serves it directly)
$uploadDir = App::getInstance()->publicPath() . '/assets/uploads/branding/';
if (!is_dir($uploadDir)) {
mkdir($uploadDir, 0755, true);
}
......@@ -78,8 +78,8 @@ class BrandingController extends Controller
@unlink($oldPath);
}
// Save path to config
SystemConfig::set('branding.logo_path', 'storage/uploads/branding/' . $storedFilename);
// Save path to config (relative to public/)
SystemConfig::set('branding.logo_path', 'assets/uploads/branding/' . $storedFilename);
BrandingService::clearCache();
}
}
......
......@@ -60,9 +60,7 @@ class BrandingService
$data = self::load();
$path = $data['logo_path'] ?? null;
if ($path && $path !== '') {
// Return as web-accessible URL relative to public/
// Logo is stored in storage/uploads/branding/ — we need to serve it
// via a relative path from the app root
// Path is relative to public/ (e.g. "assets/uploads/branding/logo_xxx.png")
$basePath = rtrim(parse_url(config('app.url', ''), PHP_URL_PATH) ?: '', '/');
return $basePath . '/' . ltrim($path, '/');
}
......@@ -77,7 +75,8 @@ class BrandingService
$data = self::load();
$path = $data['logo_path'] ?? null;
if ($path && $path !== '') {
$full = App::getInstance()->basePath() . '/' . ltrim($path, '/');
// Logo lives inside public/ directory
$full = App::getInstance()->publicPath() . '/' . ltrim($path, '/');
return file_exists($full) ? $full : null;
}
return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment