Add autoindexing
This commit is contained in:
46
app/Jobs/Tasks/PublishIndexPostTask.php
Normal file
46
app/Jobs/Tasks/PublishIndexPostTask.php
Normal 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) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user