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

fixedimage

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