From 012e7c92e9d3dab296d11dc22b6cac52675f3dab Mon Sep 17 00:00:00 2001 From: Vasyka Date: Fri, 8 May 2026 10:06:30 +0000 Subject: [PATCH] debug: /debug-storage route to inspect symlink + media state --- routes/web.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/routes/web.php b/routes/web.php index 3ec033e..2bda3a7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -46,6 +46,46 @@ Route::post('/payments/paypal/webhook', [\App\Http\Controllers\PaymentController Route::post('/payments/paynet/webhook', [\App\Http\Controllers\PaymentController::class, 'paynetWebhook']) ->withoutMiddleware([\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken::class]); +// DEBUG — verifică starea storage symlink + media library. +// TODO: remove after debug. +Route::get('/debug-storage', function () { + $publicStoragePath = public_path('storage'); + $storageAppPublic = storage_path('app/public'); + + // Try to write a test file + if (! is_dir($storageAppPublic)) @mkdir($storageAppPublic, 0775, true); + @file_put_contents($storageAppPublic . '/test.txt', 'OK ' . now()->toIso8601String()); + + $latestMedia = \DB::table('media')->latest('id')->first(); + + return response()->json([ + 'public_storage' => [ + 'path' => $publicStoragePath, + 'is_link' => is_link($publicStoragePath), + 'exists' => file_exists($publicStoragePath), + 'target' => is_link($publicStoragePath) ? readlink($publicStoragePath) : null, + 'is_dir' => is_dir($publicStoragePath), + ], + 'storage_app_public' => [ + 'path' => $storageAppPublic, + 'exists' => is_dir($storageAppPublic), + 'test_file_written' => file_exists($storageAppPublic . '/test.txt'), + 'test_file_url' => url('/storage/test.txt'), + ], + 'latest_media' => $latestMedia ? [ + 'id' => $latestMedia->id, + 'model' => $latestMedia->model_type . '#' . $latestMedia->model_id, + 'collection' => $latestMedia->collection_name, + 'name' => $latestMedia->file_name, + 'disk' => $latestMedia->disk, + 'expected_path' => $storageAppPublic . '/' . $latestMedia->id . '/' . $latestMedia->file_name, + 'file_exists' => file_exists($storageAppPublic . '/' . $latestMedia->id . '/' . $latestMedia->file_name), + ] : null, + 'media_disk_config' => config('media-library.disk_name'), + 'app_url' => config('app.url'), + ]); +}); + // Stub `login` route — needed because Laravel's auth middleware tries to // route('login') when redirecting unauthenticated requests. We don't have a // global /login (panels use /admin/login and /app/login), so stub it.