в админке в таблицу агентов вывел название агентства

This commit is contained in:
developer 2026-04-21 14:59:21 +08:00
parent ec361ad759
commit 4886817adf
2 changed files with 12 additions and 2 deletions

View File

@ -33,6 +33,9 @@
<thead> <thead>
<tr scope="col"> <tr scope="col">
<th>ФИО <th>ФИО
@if($role == 3)
<th>Агентство
@endif
<th>Email <th>Email
<th>Телефон <th>Телефон
<th>Создан <th>Создан
@ -45,6 +48,9 @@
<td class="align-middle"> <td class="align-middle">
{{ $user->name }} {{ $user->name }}
</td> </td>
@if($role == 3)
<td class="align-middle">{{ AgentCompanyOfUser($user)?->name }}</td>
@endif
<td class="align-middle"> <td class="align-middle">
{{ $user->email }} {{ $user->email }}
</td> </td>

View File

@ -7,6 +7,7 @@
use Modules\Main\Models\Agent\Agent; use Modules\Main\Models\Agent\Agent;
use Modules\Main\Models\Complex; use Modules\Main\Models\Complex;
use Modules\User\Models\Role; use Modules\User\Models\Role;
use Modules\User\Models\User;
use Modules\User\Models\UserRole; use Modules\User\Models\UserRole;
if (!function_exists('AdminCompanyOfUser')) { if (!function_exists('AdminCompanyOfUser')) {
@ -21,10 +22,13 @@ function AdminCompanyOfUser()
} }
if (!function_exists(function: 'AgentCompanyOfUser')) { if (!function_exists(function: 'AgentCompanyOfUser')) {
function AgentCompanyOfUser() function AgentCompanyOfUser(User $user = null)
{ {
if (!$user) {
$user = auth()->user();
}
$city = false; $city = false;
if ($adminAccount = Agent::where('user_id', auth()->user()->id)->first()) { if ($adminAccount = Agent::where('user_id', $user->id)->first()) {
return $adminAccount->company; return $adminAccount->company;
} else { } else {
return false; return false;