в форму создания клиентов добавил разделение агентов по компаниям

This commit is contained in:
developer 2026-04-28 13:51:15 +08:00
parent 184c0e20ea
commit 0262ac99db
2 changed files with 11 additions and 1 deletions

View File

@ -217,11 +217,20 @@ class="bi bi-plus-circle" viewBox="0 0 16 16">
<select wire:model.live="agentId" class="form-select rounded-4 @error('agentId') is-invalid @enderror"
id="agentId" name="agent" aria-label="Агент">
<option selected></option>
@foreach ($availableAgents as $agent)
@php($currentCompanyId = false)
@foreach ($availableAgents as $num=>$agent)
@if($currentCompanyId !== $agent['company_id'])
@if($num !== 0)
</optgroup>
@endif
<optgroup label="{{ $agent['company']['name'] }}">
@php( $currentCompanyId = $agent['company_id'])
@endif
<option value="{{ $agent['id'] }}">
{{ $agent['user']['name'] }}
</option>
@endforeach
</optgroup>
</select>
<label for="agentId">Агент</label>
@error('agentId')

View File

@ -59,6 +59,7 @@ function GetAvailableAgents($resultType = 'Collection')
}
$agents->with('company:id,name');
$agents->with('user:id,name');
$agents->orderBy('company_id');
if ($resultType == 'Collection') {
return $agents->get();
} else {