first
This commit is contained in:
35
app/Actions/TransferOwnershipAction.php
Normal file
35
app/Actions/TransferOwnershipAction.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user