fix: poin kehadiran dibuat otomatis via AttachAction after hook
This commit is contained in:
@@ -4,7 +4,6 @@ namespace App\Observers;
|
||||
|
||||
use App\Models\Activity;
|
||||
use App\Models\ActivityLog;
|
||||
use App\Models\MemberPoint;
|
||||
use App\Services\NotificationService;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@@ -67,21 +66,4 @@ class ActivityObserver
|
||||
'description' => "Kegiatan baru dibuat: {$activity->title}",
|
||||
]);
|
||||
}
|
||||
|
||||
public function pivotAttached(Activity $activity, string $relationName, array $pivotIds, array $pivotIdsAttributes): void
|
||||
{
|
||||
if ($relationName !== 'participants') return;
|
||||
|
||||
foreach ($pivotIdsAttributes as $userId => $attrs) {
|
||||
if (($attrs['status'] ?? 'hadir') === 'hadir') {
|
||||
MemberPoint::create([
|
||||
'user_id' => $userId,
|
||||
'points' => 10,
|
||||
'reason' => "Hadir di kegiatan: {$activity->title}",
|
||||
'source_type' => 'activity',
|
||||
'source_id' => $activity->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user