<?php

namespace App\Services;

use App\Models\EditorUpload;
use App\Models\User;
use Illuminate\Http\UploadedFile;
use Spatie\MediaLibrary\MediaCollections\Models\Media;

class MediaUploadService
{
    public function store(User $user, UploadedFile $file, string $collection = 'content'): Media
    {
        $upload = EditorUpload::create(['uploaded_by' => $user->id]);

        return $upload->addMedia($file)->toMediaCollection($collection);
    }
}
