notificationtest gerepareerd
This commit is contained in:
@@ -100,6 +100,27 @@ class Mutation extends Model
|
||||
|
||||
static::updated(function (Mutation $mutation) {
|
||||
if ($mutation->wasChanged('status')) {
|
||||
|
||||
$status = $mutation->getAttribute('status');
|
||||
$user = request()->user();
|
||||
$ledger = $mutation->ledger;
|
||||
$mutationMsg = $mutation->chat->messages()->create([
|
||||
'user_id' => null,
|
||||
'content' => $status === 'approved'
|
||||
? "<user:{$user->uuid}> APPROVED the suggestion \"{$mutation->description}\" for ".($mutation->amount >= 0 ? '+' : '')."{$mutation->amount} points on \"{$ledger->name}\" ledger."
|
||||
: "<user:{$user->uuid}> DENIED the suggestion \"{$mutation->description}\" for ".($mutation->amount >= 0 ? '+' : '')."{$mutation->amount} points on \"{$ledger->name}\" ledger.",
|
||||
'subject_id' => $mutation->id,
|
||||
'subject_type' => Mutation::class,
|
||||
]);
|
||||
|
||||
$dynamic = $ledger->dynamic;
|
||||
$dynamic->chat->messages()->create([
|
||||
'user_id' => null,
|
||||
'content' => $mutationMsg->content,
|
||||
'subject_id' => $mutation->id,
|
||||
'subject_type' => Mutation::class,
|
||||
]);
|
||||
|
||||
broadcast(new \App\Events\MutationUpdated($mutation));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user