refactor: Relocate real-time mutation broadcasts to model hooks
This commit is contained in:
parent
d68fc33bcb
commit
af1eabfa01
@ -71,9 +71,6 @@ class MutationController extends Controller
|
|||||||
return $mutation;
|
return $mutation;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Broadcast the real-time creation event!
|
|
||||||
broadcast(new MutationCreated($mutation));
|
|
||||||
|
|
||||||
return redirect()->route('dynamics.ledgers.show', [$dynamic, $ledger]);
|
return redirect()->route('dynamics.ledgers.show', [$dynamic, $ledger]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,9 +146,6 @@ class MutationController extends Controller
|
|||||||
}
|
}
|
||||||
broadcast(new MessageSent($dynamicMsg));
|
broadcast(new MessageSent($dynamicMsg));
|
||||||
|
|
||||||
// Broadcast the real-time update event!
|
|
||||||
broadcast(new MutationUpdated($mutation));
|
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -92,6 +92,15 @@ class Mutation extends Model
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
broadcast(new MessageSent($dynamicMsg));
|
broadcast(new MessageSent($dynamicMsg));
|
||||||
|
|
||||||
|
// Trigger the real-time creation broadcast dynamically
|
||||||
|
broadcast(new \App\Events\MutationCreated($mutation));
|
||||||
|
});
|
||||||
|
|
||||||
|
static::updated(function (Mutation $mutation) {
|
||||||
|
if ($mutation->wasChanged('status')) {
|
||||||
|
broadcast(new \App\Events\MutationUpdated($mutation));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user