в форму создания клиентов добавил разделение агентов по компаниям
This commit is contained in:
parent
184c0e20ea
commit
0262ac99db
@ -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"
|
<select wire:model.live="agentId" class="form-select rounded-4 @error('agentId') is-invalid @enderror"
|
||||||
id="agentId" name="agent" aria-label="Агент">
|
id="agentId" name="agent" aria-label="Агент">
|
||||||
<option selected></option>
|
<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'] }}">
|
<option value="{{ $agent['id'] }}">
|
||||||
{{ $agent['user']['name'] }}
|
{{ $agent['user']['name'] }}
|
||||||
</option>
|
</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
<label for="agentId">Агент</label>
|
<label for="agentId">Агент</label>
|
||||||
@error('agentId')
|
@error('agentId')
|
||||||
|
|||||||
@ -59,6 +59,7 @@ function GetAvailableAgents($resultType = 'Collection')
|
|||||||
}
|
}
|
||||||
$agents->with('company:id,name');
|
$agents->with('company:id,name');
|
||||||
$agents->with('user:id,name');
|
$agents->with('user:id,name');
|
||||||
|
$agents->orderBy('company_id');
|
||||||
if ($resultType == 'Collection') {
|
if ($resultType == 'Collection') {
|
||||||
return $agents->get();
|
return $agents->get();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user