splitting into components
This commit is contained in:
@@ -67,6 +67,30 @@ class MutationController extends Controller
|
||||
return $mutation;
|
||||
});
|
||||
|
||||
// Log to Mutation and Dynamic chats
|
||||
$user = $request->user();
|
||||
|
||||
$mutationMsg = $mutation->chat->messages()->create([
|
||||
'user_id' => $user->id,
|
||||
'content' => $status === 'approved'
|
||||
? "System: Entry was created by {$user->name}."
|
||||
: "System: Suggestion was created by {$user->name}.",
|
||||
]);
|
||||
broadcast(new \App\Events\MessageSent($mutationMsg));
|
||||
|
||||
if ($status === 'approved') {
|
||||
$dynamicMsg = $dynamic->chat->messages()->create([
|
||||
'user_id' => $user->id,
|
||||
'content' => "System: {$user->name} added entry \"{$mutation->description}\" for " . ($mutation->amount >= 0 ? '+' : '') . "{$mutation->amount} points on \"{$ledger->name}\" ledger.",
|
||||
]);
|
||||
} else {
|
||||
$dynamicMsg = $dynamic->chat->messages()->create([
|
||||
'user_id' => $user->id,
|
||||
'content' => "System: {$user->name} suggested \"{$mutation->description}\" for " . ($mutation->amount >= 0 ? '+' : '') . "{$mutation->amount} points on \"{$ledger->name}\" ledger.",
|
||||
]);
|
||||
}
|
||||
broadcast(new \App\Events\MessageSent($dynamicMsg));
|
||||
|
||||
// Broadcast the real-time creation event!
|
||||
broadcast(new \App\Events\MutationCreated($mutation));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user