added login user assign company control

This commit is contained in:
Cüneyt Şentürk
2023-05-10 12:02:27 +03:00
parent 97137ec0bf
commit e6c5047145
2 changed files with 95 additions and 56 deletions

View File

@ -57,7 +57,9 @@ class Users extends Controller
$landing_pages = $u->landing_pages; $landing_pages = $u->landing_pages;
return view('auth.users.show', compact('user', 'landing_pages')); $companies = $user->companies()->collect();
return view('auth.users.show', compact('user', 'landing_pages', 'companies'));
} }
/** /**

View File

@ -160,65 +160,102 @@
</x-table.thead> </x-table.thead>
<x-table.tbody> <x-table.tbody>
@foreach($user->companies as $item) @foreach($companies as $item)
<x-table.tr> @if (in_array($item->id, user()->company_ids))
<x-table.td class="w-2/12 sm:w-1/12"> <x-table.tr>
{{ $item->id }} <x-table.td class="w-2/12 sm:w-1/12">
</x-table.td> {{ $item->id }}
</x-table.td>
<x-table.td class="w-8/12 sm:w-4/12"> <x-table.td class="w-8/12 sm:w-4/12">
<x-slot name="first" class="flex" override="class"> <x-slot name="first" class="flex" override="class">
<div class="font-bold truncate"> <div class="font-bold truncate">
{{ $item->name }} {{ $item->name }}
</div> </div>
@if (! $item->enabled) @if (! $item->enabled)
<x-index.disable text="{{ trans_choice('general.companies', 1) }}" /> <x-index.disable text="{{ trans_choice('general.companies', 1) }}" />
@endif @endif
</x-slot> </x-slot>
<x-slot name="second"> <x-slot name="second">
@if ($item->tax_number) @if ($item->tax_number)
{{ $item->tax_number }} {{ $item->tax_number }}
@else @else
<x-empty-data /> <x-empty-data />
@endif @endif
</x-slot> </x-slot>
</x-table.td> </x-table.td>
<x-table.td class="w-4/12" hidden-mobile> <x-table.td class="w-4/12" hidden-mobile>
<x-slot name="first"> <x-slot name="first">
@if ($item->email) @if ($item->email)
{{ $item->email }} {{ $item->email }}
@else @else
<x-empty-data /> <x-empty-data />
@endif @endif
</x-slot> </x-slot>
<x-slot name="second"> <x-slot name="second">
@if ($item->phone) @if ($item->phone)
{{ $item->phone }} {{ $item->phone }}
@else @else
<x-empty-data /> <x-empty-data />
@endif @endif
</x-slot> </x-slot>
</x-table.td> </x-table.td>
<x-table.td class="w-3/12" kind="amount"> <x-table.td class="w-3/12" kind="amount">
<x-slot name="first"> <x-slot name="first">
@if ($item->country) @if ($item->country)
<x-index.country code="{{ $item->country }}" /> <x-index.country code="{{ $item->country }}" />
@else @else
<x-empty-data /> <x-empty-data />
@endif @endif
</x-slot> </x-slot>
<x-slot name="second"> <x-slot name="second">
@if ($item->currency) @if ($item->currency)
<x-index.currency code="{{ $item->currency }}" /> <x-index.currency code="{{ $item->currency }}" />
@else @else
<x-empty-data /> <x-empty-data />
@endif @endif
</x-slot> </x-slot>
</x-table.td> </x-table.td>
</x-table.tr> </x-table.tr>
@else
<x-table.tr>
<x-table.td class="w-2/12 sm:w-1/12">
***
</x-table.td>
<x-table.td class="w-8/12 sm:w-4/12">
<x-slot name="first" class="flex" override="class">
<div class="font-bold truncate">
***
</div>
</x-slot>
<x-slot name="second">
***
</x-slot>
</x-table.td>
<x-table.td class="w-4/12" hidden-mobile>
<x-slot name="first">
***
</x-slot>
<x-slot name="second">
***
</x-slot>
</x-table.td>
<x-table.td class="w-3/12" kind="amount">
<x-slot name="first">
***
</x-slot>
<x-slot name="second">
***
</x-slot>
</x-table.td>
</x-table.tr>
@endif
@endforeach @endforeach
</x-table.tbody> </x-table.tbody>
</x-table> </x-table>