Skip to content

Commit

Permalink
Open chat function create
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed May 19, 2024
1 parent d69b3ee commit e58789d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/Livewire/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@ class Messages extends Component
public $loggedInUser;
public $currentUserRole;
public $search = '';
public $selectedUser;
public $message;
public $messages;

public function mount(): void
{
$this->loggedInUser = auth()->user();
$this->currentUserRole = $this->loggedInUser->role;
}

//openChat
public function openChat($id): void
{
$this->selectedUser = User::find($id);
$this->messages = $this->loggedInUser->messages()->where('receiver_id', $id)->orWhere('sender_id', $id)->get();
}

public function render(): View
{
return view('messages',
Expand Down

0 comments on commit e58789d

Please sign in to comment.