jonnybarnes.uk/app/Jobs/AddClientToDatabase.php

48 lines
1 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
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;
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;
class AddClientToDatabase implements ShouldQueue
{
2019-10-27 19:31:33 +00:00
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
protected $client_id;
/**
* Create a new job instance.
*
2022-07-09 10:08:26 +01:00
* @param string $client_id
*/
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([
'client_url' => $this->client_id,
'client_name' => $this->client_id, // default client name is the URL
]);
}
}
}