Feature: Handling Cases for User to Customer Relationships
This commit handles a case where customer data are "dead-data" menaing there is no way of erasure for them, which makes the app non-compliant
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace Modules\Core\Privacy\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Lunar\Models\Customer;
|
||||
use Modules\Core\Privacy\ErasureRequestStatus;
|
||||
@@ -44,6 +46,25 @@ class DataErasureRequest extends Model
|
||||
return $this->morphTo(__FUNCTION__, 'requested_by_type', 'requested_by_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* The User erasure request that caused this one to be auto-created, if any —
|
||||
* see Modules\Core\Privacy\Listeners\CascadeCustomerErasureListener.
|
||||
*/
|
||||
public function causedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(self::class, 'caused_by_request_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Every Customer erasure request THIS request caused (see causedBy()) —
|
||||
* used by CancelErasureOnLoginListener to revert exactly the cascade this
|
||||
* User's own cancellation should undo.
|
||||
*/
|
||||
public function caused(): HasMany
|
||||
{
|
||||
return $this->hasMany(self::class, 'caused_by_request_id');
|
||||
}
|
||||
|
||||
public function isForCustomer(): bool
|
||||
{
|
||||
return $this->subject_type === (new Customer)->getMorphClass();
|
||||
|
||||
Reference in New Issue
Block a user