debug: /debug-storage route to inspect symlink + media state
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user