Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(game): add game_sets attach/detach actions to game audit logs #3167

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions app/Models/GameSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ public static function boot()
])
->event('pivotAttached')
->log('pivotAttached');

// Log the attachment on each game model.
foreach ($attachedGames as $game) {
$attribute = $model->type === GameSetType::Hub ? 'hubs' : 'similarGames';

activity()->causedBy($user)->performedOn($game)
->withProperty('old', [$attribute => null])
->withProperty('attributes', [$attribute => [
'id' => $model->id,
'title' => $model->title,
]])
->event('pivotAttached')
->log('pivotAttached');
}
Jamiras marked this conversation as resolved.
Show resolved Hide resolved
}

if ($relationName === 'parents') {
Expand Down Expand Up @@ -121,6 +135,20 @@ public static function boot()
->withProperty('attributes', [$relationName => null])
->event('pivotDetached')
->log('pivotDetached');

// Log the detachment on each game model.
foreach ($detachedGames as $game) {
$attribute = $model->type === GameSetType::Hub ? 'hubs' : 'similarGames';

activity()->causedBy($user)->performedOn($game)
->withProperty('old', [$attribute => [
'id' => $model->id,
'title' => $model->title,
]])
->withProperty('attributes', [$attribute => null])
->event('pivotDetached')
->log('pivotDetached');
}
}

if ($relationName === 'parents') {
Expand Down