36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Actions;
|
|
|
|
use App\Models\TranscriptionProject;
|
|
use App\Models\User;
|
|
use App\Services\AuditLogService;
|
|
|
|
class TransferOwnershipAction
|
|
{
|
|
public function __construct(private readonly AuditLogService $audit) {}
|
|
|
|
public function execute(TranscriptionProject $project, User $newOwner, string $justification): void
|
|
{
|
|
$oldOwner = $project->owner;
|
|
|
|
$project->update(['owner_user_id' => $newOwner->id]);
|
|
|
|
$this->audit->log('project_ownership_transferred', [
|
|
'subject_type' => TranscriptionProject::class,
|
|
'subject_id' => $project->id,
|
|
'project_id' => $project->id,
|
|
'target_user_id' => $newOwner->id,
|
|
'old_values' => [
|
|
'owner_user_id' => $oldOwner?->id,
|
|
'owner_name' => $oldOwner?->name,
|
|
],
|
|
'new_values' => [
|
|
'owner_user_id' => $newOwner->id,
|
|
'owner_name' => $newOwner->name,
|
|
],
|
|
'justification' => $justification,
|
|
]);
|
|
}
|
|
}
|