<?php

namespace App\Http\Controllers;

use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class UploadController extends Controller
{
    public function image(Request $request): JsonResponse
    {
        $request->validate([
            'file' => 'required|image|max:10240',
        ]);

        $path = $request->file('file')->store('covers', 'public');

        return response()->json(['path' => $path]);
    }

    public function audio(Request $request): JsonResponse
    {
        $request->validate([
            'file' => 'required|file|mimes:mp3,wav,flac,ogg,aac|max:51200',
        ]);

        $path = $request->file('file')->store('tracks', 'public');

        return response()->json(['path' => $path]);
    }
}
