Add autoindexing

This commit is contained in:
2023-11-28 15:44:01 +08:00
parent 5d418adb7d
commit 94d07a5d21
5 changed files with 95 additions and 7 deletions

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Jobs\Tasks;
use App\Models\AiTool;
use App\Notifications\PostWasPublished;
use Exception;
use Illuminate\Support\Facades\Notification;
use LaravelFreelancerNL\LaravelIndexNow\Facades\IndexNow;
use LaravelGoogleIndexing;
class PublishIndexPostTask
{
public static function handle(int $ai_tool_id)
{
$ai_tool = AiTool::find($ai_tool_id);
if (is_null($ai_tool)) {
return;
}
if (!$ai_tool->is_ai_tool)
{
return ;
}
if ((app()->environment() == 'production') && (config('platform.general.indexing'))) {
$ai_tool_url = route('front.aitool.show', ['ai_tool_slug' => $ai_tool->slug]);
try {
IndexNow::submit($post_url);
} catch (Exception) {
}
try {
LaravelGoogleIndexing::create()->update($post_url);
} catch (Exception) {
}
}
}