31 lines
842 B
PHP
31 lines
842 B
PHP
<?php
|
|
|
|
namespace App\Integrations\Domain\Writers;
|
|
|
|
use App\Integrations\Domain\DTOs\DnsDomainUserData;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class DnsDomainUserWriter
|
|
{
|
|
/**
|
|
* Skips pairs whose domain or customer couldn't be resolved — both columns are NOT NULL.
|
|
* Matched on (domain_id, user_id), the pivot's own unique key — no legacy_id needed.
|
|
*/
|
|
public function write(DnsDomainUserData $data): bool
|
|
{
|
|
if ($data->domainId === null || $data->customerId === null) {
|
|
return false;
|
|
}
|
|
|
|
DB::table('dns_domain_user')->updateOrInsert(
|
|
['domain_id' => $data->domainId, 'user_id' => $data->customerId],
|
|
[
|
|
'created_at' => $data->createdAt,
|
|
'updated_at' => $data->updatedAt,
|
|
]
|
|
);
|
|
|
|
return true;
|
|
}
|
|
}
|