them log, chinh upload
This commit is contained in:
27
app/Services/ActivityLogger.php
Normal file
27
app/Services/ActivityLogger.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ActivityLogger
|
||||
{
|
||||
public static function log(
|
||||
string $action,
|
||||
string $description,
|
||||
?Model $subject = null,
|
||||
?array $metadata = null,
|
||||
?int $userId = null,
|
||||
): ActivityLog {
|
||||
return ActivityLog::create([
|
||||
'user_id' => $userId ?? auth()->id(),
|
||||
'action' => $action,
|
||||
'description' => $description,
|
||||
'subject_type' => $subject ? get_class($subject) : null,
|
||||
'subject_id' => $subject?->id,
|
||||
'metadata' => $metadata,
|
||||
'created_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -38,8 +38,20 @@ class ClosingService
|
||||
]);
|
||||
}
|
||||
|
||||
$previousStatus = $feedback->status;
|
||||
|
||||
$feedback->update(['status' => 'closed']);
|
||||
|
||||
ActivityLogger::log(
|
||||
'close',
|
||||
__('feedback.log_close', ['title' => $feedback->title]),
|
||||
$feedback,
|
||||
[
|
||||
'feedback_id' => $feedback->id,
|
||||
'previous_status' => $previousStatus,
|
||||
],
|
||||
);
|
||||
|
||||
$this->notifyStakeholders($feedback, $actor);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class FileService
|
||||
'video/mov',
|
||||
];
|
||||
|
||||
protected int $maxSize = 20480;
|
||||
protected int $maxSize = 51200;
|
||||
|
||||
protected string $defaultDisk = 'public';
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Models\Department;
|
||||
use App\Models\Feedback;
|
||||
use App\Models\TicketTransferLog;
|
||||
use App\Models\User;
|
||||
use App\Services\ActivityLogger;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class TransferService
|
||||
@@ -24,6 +25,7 @@ class TransferService
|
||||
}
|
||||
|
||||
$fromDepartmentId = $feedback->current_department_id;
|
||||
$fromDepartmentName = $feedback->currentDepartment?->name ?? 'N/A';
|
||||
|
||||
$log = TicketTransferLog::create([
|
||||
'feedback_id' => $feedback->id,
|
||||
@@ -40,6 +42,22 @@ class TransferService
|
||||
|
||||
$this->notifyDepartmentManager($toDepartment, $feedback, $log, $sender);
|
||||
|
||||
ActivityLogger::log(
|
||||
'transfer',
|
||||
__('feedback.log_transfer', [
|
||||
'title' => $feedback->title,
|
||||
'from' => $fromDepartmentName,
|
||||
'to' => $toDepartment->name,
|
||||
]),
|
||||
$feedback,
|
||||
[
|
||||
'feedback_id' => $feedback->id,
|
||||
'from_department' => $fromDepartmentName,
|
||||
'to_department' => $toDepartment->name,
|
||||
'reason' => $reason,
|
||||
],
|
||||
);
|
||||
|
||||
return $log;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user