chore: update composer dependencies to include phppresentation chore: update composer.lock after adding phppresentation feat: create categories migration for category management feat: create templates migration for template storage feat: create template generations migration for tracking template usage feat: create template keys migration for template customization feat: create notifications migration for user notifications feat: update API routes for categories, templates, and user profile management docs: update API documentation to include new endpoints for profile and wallet
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Enums\TemplateGenerationStatus;
|
|
use App\Models\TemplateGeneration;
|
|
use App\Services\TemplateFillService;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Throwable;
|
|
|
|
class GenerateTemplateJob implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
public function __construct(private readonly TemplateGeneration $generation) {}
|
|
|
|
public function handle(TemplateFillService $templateFillService): void
|
|
{
|
|
$this->generation->update(['status' => TemplateGenerationStatus::Processing]);
|
|
|
|
try {
|
|
$outputPath = $templateFillService->fill($this->generation);
|
|
|
|
$this->generation->update([
|
|
'status' => TemplateGenerationStatus::Completed,
|
|
'output_path' => $outputPath,
|
|
]);
|
|
} catch (Throwable $exception) {
|
|
$this->generation->update([
|
|
'status' => TemplateGenerationStatus::Failed,
|
|
'error_message' => $exception->getMessage(),
|
|
]);
|
|
}
|
|
}
|
|
}
|