<?php
// routes/api.php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Storage;

Route::post('/storage', function (Request $request) {
    $request->validate([
        'file' => 'required|image|mimes:jpg,jpeg,png,gif|max:2048',
    ]);

    $path = $request->file('file')->store('uploads', 'public');
    $url = Storage::url($path);

    return response()->json([
        'success' => true,
        'url' => asset($url),
    ]);
});
