Update (kernel): Auto submit index
This commit is contained in:
52
app/Jobs/PublishRssSearchResultJob.php
Normal file
52
app/Jobs/PublishRssSearchResultJob.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Jobs\Tasks\PublishIndexPostTask;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use LaravelFreelancerNL\LaravelIndexNow\Facades\IndexNow;
|
||||
use LaravelGoogleIndexing;
|
||||
use Exception;
|
||||
|
||||
class PublishRssSearchResultJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $query;
|
||||
|
||||
public $timeout = 30;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(string $query)
|
||||
{
|
||||
$this->query = $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
if ((app()->environment() == 'production') && (config('platform.global.indexing'))) {
|
||||
$url = get_route_search_result(strtolower($this->query));
|
||||
|
||||
try {
|
||||
IndexNow::submit($url);
|
||||
} catch (Exception) {
|
||||
}
|
||||
|
||||
try {
|
||||
LaravelGoogleIndexing::create()->update($url);
|
||||
} catch (Exception) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user