QueenFruits/Backend/app/Services/UploadService.php

20 lines
498 B
PHP

<?php
namespace App\Services;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Auth;
class UploadService
{
public function uploadImage(UploadedFile $file, string $folderType): string
{
$tenantCode = Auth::user()->tenant->business_code;
$fileName = pathinfo($file->getClientOriginalName(), PATHINFO_BASENAME);
$targetDirectory = "{$tenantCode}/{$folderType}";
return $file->storeAs($targetDirectory, $fileName, 'public');
}
}