feat: add ApiResponse trait for standardized API responses
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
This commit is contained in:
39
app/Jobs/GenerateTemplateJob.php
Normal file
39
app/Jobs/GenerateTemplateJob.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user