Level 104
@enasalh please format your code correctly by wrapping it within triple backticks
```
// your code
```
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have 2 component in livewire 3, and I want to refresh content after function is finish, I try dispatch('event-name') and it works for some functions but the case that I have is about Move() function which move user from group to another, it refresh the first group (from) but the second group no (to), here is my code:
class AssessmentDetails extends Component
{ /// ....
public function refreshUsers()
{
$this->users = Report_360Invitations::whereIn('user_group', [
RequestConstants::SELF,
RequestConstants::MANAGERS,
RequestConstants::PEERS,
RequestConstants::SUBORDINATE,
RequestConstants::FRIENDS_FAMILY,
RequestConstants::OTHER
])->get();
}
#[On('user-moved')]
#[On('invitation')]
#[On('invitation-deleted')]
#[On('invitation-resend')]
public function render()
{
$this->refreshUsers();
return view('livewire.assessment-details');
}
} and in UserItem component:public function move()
{
$selectedGroup = $this->group;
$managerCount = Report_360Invitations::where('user_group', RequestConstants::MANAGERS)
->where('request_id', $this->requestId)
->count();
// check permission
$userAction = auth()->user()->user_id;
$userRole = UserRole::where('user_id', $userAction)->select('role_type')->first();
if ($userRole->role_type != UserConstants::ADMIN) {
return Notification::make()
->title(__('Sorry'))
->body(__('You do not have permission to this action.'))
->status('danger')
->send();
} else {
if ($selectedGroup == RequestConstants::MANAGERS) {
if ($managerCount >= 1) {
return Notification::make()
->title(__('Sorry'))
->body(__('You cannot move user to this group because there is already manager exist.'))
->status('warning')
->send();
}
}
if ($this->role == $selectedGroup) {
return Notification::make()
->title(__('Sorry'))
->body(__('The user is already in the selected group, please chose another group.'))
->status('danger')
->send();
}
$invitationId = Report_360Invitations::where('id', $this->inviteId);
if ($invitationId) {
$invitationId->update([
'user_group' => $selectedGroup,
'updated_by' => auth()->user()->user_id,
]);
$this->dispatch('user-moved');
Notification::make()
->title(__('Moved Successfully'))
->body(__('The user has been moved successfully to the new group.'))
->status('success')
->send();
} else {
Notification::make()
->title(__('Error'))
->body(__('No record found for the specified request ID.'))
->status('danger')
->send();
}
}
}
Please or to participate in this conversation.