Initial baseline: LaraBlog core with plugin commerce surface.
Captures the current working tree after theme slots, ArticleAccess, and the payment / paid-content plugins so subsequent work has a reviewable git history.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Domain\Ai\Jobs;
|
||||
|
||||
use App\Contracts\LlmProvider;
|
||||
use App\Models\Article;
|
||||
use App\Settings\AiSettings;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class OptimizeArticleContentJob implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public int $articleId,
|
||||
) {
|
||||
$this->onQueue('ai-content');
|
||||
}
|
||||
|
||||
public function handle(LlmProvider $llm, AiSettings $settings): void
|
||||
{
|
||||
if (! $settings->content_optimization_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$article = Article::query()->find($this->articleId);
|
||||
|
||||
if ($article === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$result = $llm->complete($article->content, [
|
||||
'title' => $article->title,
|
||||
'article_id' => $article->id,
|
||||
]);
|
||||
|
||||
$article->forceFill([
|
||||
'ai_summary' => $result['summary'] ?? null,
|
||||
'ai_suggestions' => $result['suggestions'] ?? [],
|
||||
])->save();
|
||||
} catch (\Throwable $exception) {
|
||||
Log::warning('Article content optimization failed.', [
|
||||
'article_id' => $this->articleId,
|
||||
'message' => $exception->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user