Initial commit

This commit is contained in:
2026-02-03 10:38:46 +01:00
commit eb304f4b14
144 changed files with 22605 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
<?php
namespace App\Jobs;
use App\Models\Upload;
use App\Services\GoogleDrive\GoogleDriveService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class ProcessEventUpload implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public int $tries = 3;
public function __construct(
public Upload $upload,
public string $tempFilePath
) {}
public function handle(GoogleDriveService $googleDrive): void
{
$upload = $this->upload;
$event = $upload->event;
$user = $event->user;
$upload->update(['status' => 'uploading', 'upload_started_at' => now()]);
try {
if (! $event->google_drive_folder_id) {
throw new \RuntimeException('Event has no Google Drive folder configured.');
}
if (! file_exists($this->tempFilePath)) {
throw new \RuntimeException('Temporary file not found.');
}
$result = $googleDrive->uploadFile(
$user,
$this->tempFilePath,
$event->google_drive_folder_id,
$upload->original_filename,
$upload->mime_type
);
$upload->update([
'google_drive_file_id' => $result['id'],
'google_drive_web_link' => $result['webViewLink'] ?? null,
'status' => 'completed',
'upload_completed_at' => now(),
'error_message' => null,
]);
} catch (\Throwable $e) {
$upload->update([
'status' => 'failed',
'error_message' => $e->getMessage(),
'upload_completed_at' => now(),
]);
throw $e;
} finally {
if (file_exists($this->tempFilePath)) {
@unlink($this->tempFilePath);
}
}
}
}