Snapshot of main at 9f39a6e1e (2026-11-02)
This commit is contained in:
commit
6ccf1792d7
2580 files changed
+1040202
No files matched your search
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\WireChat\New;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Namu\WireChat\Facades\WireChat;
|
||||
use Namu\WireChat\Livewire\New\Group as BaseGroup;
|
||||
|
||||
class Group extends BaseGroup
|
||||
{
|
||||
/**
|
||||
* Add all linked users of the active Organization, Bank, or Admin profile
|
||||
* to the selected members list, up to the group member limit.
|
||||
*/
|
||||
public function addLinkedMembers(): void
|
||||
{
|
||||
$activeProfile = getActiveProfile();
|
||||
if (!$activeProfile) {
|
||||
return;
|
||||
}
|
||||
|
||||
\App\Helpers\ProfileAuthorizationHelper::authorize($activeProfile);
|
||||
|
||||
$activeProfileType = getActiveProfileType();
|
||||
|
||||
if (!in_array($activeProfileType, ['Organization', 'Bank', 'Admin'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$relationMethod = $activeProfileType === 'Bank' ? 'managers' : 'users';
|
||||
$linkedUsers = $activeProfile->$relationMethod()
|
||||
->select('users.id')
|
||||
->get();
|
||||
|
||||
$maxMembers = WireChat::maxGroupMembers();
|
||||
|
||||
foreach ($linkedUsers as $linkedUser) {
|
||||
// Stop if we've hit the group member limit
|
||||
if (count($this->selectedMembers) >= $maxMembers) {
|
||||
$this->dispatch('show-member-limit-error');
|
||||
break;
|
||||
}
|
||||
|
||||
$user = User::find($linkedUser->id);
|
||||
if (!$user) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip if already selected
|
||||
if ($this->selectedMembers->contains(fn ($m) => $m->id == $user->id && get_class($m) == get_class($user))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->selectedMembers->push($user);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user