51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use Exception;
|
|
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;
|
|
|
|
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) {
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|