���Root Mod By V1rus_Alfa
User / IP
:
216.73.216.158
Host / Server
:
195.214.235.115 / npln.ir
System
:
Linux damavand.pws-dns.net 5.14.0-503.35.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 4 05:23:43 EDT 2025 x86_64
Command
|
Upload
|
Mass Deface
|
Create
:
/
home2
/
cutunixc
/
repositories
/
portal-cutunix
/
app
/
Livewire
/
Chat
/
Viewing: CreateConversation.php
<?php namespace App\Livewire\Chat; use App\Models\Admin; use App\Models\Tenant; use App\Models\User; use App\Services\ConversationService; use Illuminate\Support\Facades\Auth; use Livewire\Component; class CreateConversation extends Component { public $title; public $selectedParticipants = []; public $searchQuery = ''; public function getParticipantsProperty() { if (empty($this->searchQuery)) { return []; } $query = $this->searchQuery; $currentUser = Auth::user(); $guard = Auth::getDefaultDriver(); // Get users based on the current authenticated user's type $results = collect(); if ($guard === 'admin') { // Admin can chat with everyone $results = $results->merge( Admin::where('id', '!=', $currentUser->id) ->where('name', 'like', "%{$query}%") ->get() ); $results = $results->merge( Tenant::where('name', 'like', "%{$query}%")->get() ); $results = $results->merge( User::where('name', 'like', "%{$query}%")->get() ); } elseif ($guard === 'tenant') { // Tenant can chat with admins, their own users, and other tenants $results = $results->merge( Admin::where('name', 'like', "%{$query}%")->get() ); $results = $results->merge( Tenant::where('id', '!=', $currentUser->id) ->where('name', 'like', "%{$query}%") ->get() ); $results = $results->merge( User::where('tenant_id', $currentUser->id) ->where('name', 'like', "%{$query}%") ->get() ); } else { // Regular user can chat with admins, their tenant, and other users of the same tenant $results = $results->merge( Admin::where('name', 'like', "%{$query}%")->get() ); $results = $results->merge( Tenant::where('id', $currentUser->tenant_id) ->where('name', 'like', "%{$query}%") ->get() ); $results = $results->merge( User::where('tenant_id', $currentUser->tenant_id) ->where('id', '!=', $currentUser->id) ->where('name', 'like', "%{$query}%") ->get() ); } return $results; } public function toggleParticipant($id, $type) { $key = "{$type}-{$id}"; if (in_array($key, $this->selectedParticipants)) { $this->selectedParticipants = array_diff($this->selectedParticipants, [$key]); } else { $this->selectedParticipants[] = $key; } } public function createConversation(ConversationService $conversationService) { $participants = []; foreach ($this->selectedParticipants as $participant) { [$type, $id] = explode('-', $participant); $model = match ($type) { 'App\\Models\\Admin' => Admin::find($id), 'App\\Models\\Tenant' => Tenant::find($id), 'App\\Models\\User' => User::find($id), }; if ($model) { $participants[] = $model; } } if (empty($participants)) { $this->addError('participants', 'Please select at least one participant.'); return; } $conversation = $conversationService->createConversation( Auth::user(), $participants, $this->title ); $this->dispatch('conversationCreated', $conversation->id); $this->reset(['title', 'selectedParticipants', 'searchQuery']); } public function render() { return view('livewire.chat.create-conversation', [ 'participants' => $this->participants ]); } }
Coded With 💗 by
0x6ick Mod By V1rus_Alfa