{{-- Merchant Users Table Component Used for displaying assigned users with split permissions @param array $assignedUsers - Collection of assigned users @param array $currentSplits - Current split data for users @param array $splitTypes - Available split types @param array $payOrders - Available pay order options @param int $merchantId - The merchant ID for history links @param bool $showActions - Whether to show action buttons (default: true) @param string $tableId - Unique table ID (default: 'merchant-users-table') --}} @php // Accept multiple possible variable names for flexibility $assignedUsers = $assignedUsers ?? $merchantUsers ?? collect(); $currentSplits = $currentSplits ?? $splits ?? collect(); $showActions = $showActions ?? true; $tableId = $tableId ?? 'merchant-users-table'; $totalPercentage = 0; // Ensure we have a collection-like structure for splits if(!($currentSplits instanceof \Illuminate\Support\Collection)) { $currentSplits = collect($currentSplits); } // Provide split types if not passed in if(!isset($splitTypes) || empty($splitTypes)) { $userModelTmp = new \App\Models\User(); $splitTypes = \App\Helpers\Helper::makeSimpleArray($userModelTmp->splitTypes, 'id,name'); } @endphp
@if($showActions) @endif @forelse($assignedUsers as $assigned) @php // Support both MerchantUserMap (with ->user relation) and direct User models $user = isset($assigned->user) ? $assigned->user : $assigned; if(!$user) continue; // Skip if relation missing $split = $currentSplits->firstWhere('user_id', $user->id); $totalPercentage += $split ? (float)$split->split_percentage : 0; $isPrimary = $assigned->is_primary ?? ($user->is_primary ?? false); $payOrderVal = $assigned->pay_order_type_id ?? $user->pay_order_type_id ?? 1; @endphp @if($showActions) @endif @empty @endforelse @if(count($assignedUsers) > 0) @endif
User Name Split Pay Order PrimaryActions
{{ $user->first_name }} {{ $user->last_name }} @if($isPrimary) Primary @endif
{{ $user->email ?? '' }}
@php // Get expiration split info using model attributes $expirationInfo = ['has_expiration' => false, 'tooltip_title' => 'Expiration Split History']; if (isset($assigned->user) && method_exists($assigned, 'getExpirationSplitInfoAttribute')) { // MerchantUserMap with attribute $expirationInfo = $assigned->expiration_split_info; } elseif (isset($merchantId)) { // Direct user object, use static method $expirationInfo = \App\Models\Merchants\MerchantUserSplitPercentage::getExpirationSplitInfo($merchantId, $user->id); } @endphp @if($expirationInfo['has_expiration']) @endif
{{ $payOrderVal }}
No users assigned to this merchant.
Total {{ number_format($totalPercentage, 2) }} %