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:
ak
2026-08-12 01:15:38 +08:00
commit 263b98b218
337 changed files with 31393 additions and 0 deletions
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace App\Domain\Ai\Jobs;
use App\Models\Article;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
/**
* Phase-2 stub: auto-pick or generate a cover image for an article.
* Dispatch later from import scripts / artisan batch; process via Workerman/queue.
*/
class GenerateArticleCoverJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function __construct(
public int $articleId,
public string $strategy = 'auto', // auto|from_content|generate
) {
$this->onQueue('ai-content');
}
public function handle(): void
{
$article = Article::query()->find($this->articleId);
if ($article === null) {
return;
}
// Intentionally unimplemented in phase 1.
Log::info('GenerateArticleCoverJob stub skipped', [
'article_id' => $article->id,
'strategy' => $this->strategy,
'cover_status' => $article->cover_status,
]);
}
}
+63
View File
@@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
namespace App\Domain\Ai\Jobs;
use App\Contracts\LlmProvider;
use App\Models\Comment;
use App\Settings\AiSettings;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Log;
class ModerateCommentJob implements ShouldQueue
{
use Queueable;
public function __construct(
public int $commentId,
) {
$this->onQueue('ai-moderation');
}
public function handle(LlmProvider $llm, AiSettings $settings): void
{
if (! $settings->comment_moderation_enabled) {
return;
}
$comment = Comment::query()->find($this->commentId);
if ($comment === null) {
return;
}
if ($comment->moderation_status !== Comment::STATUS_PENDING_AI) {
$comment->update(['moderation_status' => Comment::STATUS_PENDING_AI]);
}
try {
$result = $llm->moderate($comment->content);
$status = match ($result['status'] ?? 'needs_human') {
'approved' => Comment::STATUS_APPROVED,
'rejected' => Comment::STATUS_REJECTED,
default => Comment::STATUS_NEEDS_HUMAN,
};
$comment->forceFill([
'moderation_status' => $status,
'published_at' => $status === Comment::STATUS_APPROVED
? ($comment->published_at ?? now())
: $comment->published_at,
])->save();
} catch (\Throwable $exception) {
Log::warning('Comment moderation failed.', [
'comment_id' => $this->commentId,
'message' => $exception->getMessage(),
]);
$comment->update(['moderation_status' => Comment::STATUS_NEEDS_HUMAN]);
}
}
}
@@ -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(),
]);
}
}
}