api/app/Console/Commands/GenerateAiMealPost.php

32 lines
736 B
PHP

<?php
namespace App\Console\Commands;
use App\Services\AiMealPostGenerator;
use Illuminate\Console\Command;
use Throwable;
class GenerateAiMealPost extends Command
{
protected $signature = 'meal-posts:generate-ai';
protected $description = 'Generate one AI meal post with an image.';
public function handle(AiMealPostGenerator $generator): int
{
try {
$mealPost = $generator->generate();
} catch (Throwable $exception) {
report($exception);
$this->error('Impossible de generer le repas IA.');
return self::FAILURE;
}
$this->info("Repas IA genere: {$mealPost->title} ({$mealPost->getKey()})");
return self::SUCCESS;
}
}