2017-06-22 15:41:23 +01:00
|
|
|
<?php
|
|
|
|
|
2018-01-15 14:02:13 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2017-06-22 15:41:23 +01:00
|
|
|
namespace App\Jobs;
|
|
|
|
|
2017-12-19 16:00:42 +00:00
|
|
|
use App\Models\MicropubClient;
|
2019-10-27 16:29:15 +00:00
|
|
|
use Illuminate\Bus\Queueable;
|
2017-06-22 15:41:23 +01:00
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
2019-10-27 16:29:15 +00:00
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
2017-06-22 15:41:23 +01:00
|
|
|
|
|
|
|
class AddClientToDatabase implements ShouldQueue
|
|
|
|
{
|
2019-10-27 19:31:33 +00:00
|
|
|
use Dispatchable;
|
|
|
|
use InteractsWithQueue;
|
|
|
|
use Queueable;
|
|
|
|
use SerializesModels;
|
2017-06-22 15:41:23 +01:00
|
|
|
|
|
|
|
protected $client_id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
*/
|
|
|
|
public function __construct(string $client_id)
|
|
|
|
{
|
|
|
|
$this->client_id = $client_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
if (MicropubClient::where('client_url', $this->client_id)->count() == 0) {
|
2019-10-27 19:31:33 +00:00
|
|
|
MicropubClient::create([
|
2017-06-22 15:41:23 +01:00
|
|
|
'client_url' => $this->client_id,
|
|
|
|
'client_name' => $this->client_id, // default client name is the URL
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|