2026-08-24 21:06:11 +03:00
|
|
|
<?php
|
|
|
|
|
|
2026-09-16 01:21:22 +03:00
|
|
|
namespace Modules\Core\Privacy\DTOs;
|
2026-08-24 21:06:11 +03:00
|
|
|
|
|
|
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
|
|
|
|
use Lunar\Base\LunarUser;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Identifies "the person" for a User-scoped data-subject request — erasing/
|
|
|
|
|
* exporting one individual's own identity (login, name, email) wherever it
|
|
|
|
|
* appears, regardless of how many Customer (business) accounts they're linked to.
|
|
|
|
|
* Deliberately carries no customerId: a provider that needs to know which
|
|
|
|
|
* Customer accounts this User is linked to (e.g. to detach them, or to find data
|
|
|
|
|
* keyed by a shared email) looks that up itself, rather than this value object
|
|
|
|
|
* assuming one fixed Customer — the whole point is that one User can belong to
|
|
|
|
|
* many Customer accounts (B2B multi-seat access) and erasing the User must not
|
|
|
|
|
* assume or privilege any single one of them.
|
|
|
|
|
*/
|
|
|
|
|
class UserSubject
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
|
|
|
|
public readonly int $userId,
|
|
|
|
|
public readonly ?string $email = null,
|
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
public static function forUser(Authenticatable&LunarUser $user): self
|
|
|
|
|
{
|
|
|
|
|
return new self(userId: $user->id, email: $user->email);
|
|
|
|
|
}
|
|
|
|
|
}
|