@php use App\Models\User; // Define the roles to exclude $rolesToExclude = []; $loggedInUser = backpack_user(); $permissionsToExclude = ['hide from member commission']; // Modify the query to exclude users with the specified permissions $users = User::whereDoesntHave('permissions', function ($query) use ($permissionsToExclude) { $query->whereIn('name', $permissionsToExclude); }) ->orderBy('name', 'asc') ->get(); $project = \App\Models\Project::with([ 'lead' => function ($query) { $query->with('sales'); }, ])->find(request()->route('id')); $memberCommissions = \App\Models\ProjectMemberCommission::with('user') ->where('project_id', $project->id) ->get(); $pushMemberCommission = ''; // Extract the user_ids from memberCommissions to filter out users already assigned $existingUserIds = $memberCommissions->pluck('user_id')->toArray(); // Query users again to exclude the existing ones based on memberCommissions $users = User::with('roles') ->whereDoesntHave('permissions', function ($query) use ($permissionsToExclude) { $query->whereIn('name', $permissionsToExclude); }) ->orderBy('name', 'asc') ->get(); $totalUsers = $memberCommissions->count(); function usersWithoutCurrent($users, $current, $except = false) { $html = ''; foreach ($users as $user) { if ($user->id != $except) { $html .= ''; } } return $html; } if ($memberCommissions->count() > 0) { foreach ($memberCommissions as $memberCommission) { if ($memberCommission->is_owner) { $pushMemberCommission .= '
count() > 1 ? '' : '') . '>
'; } else { $pushMemberCommission .= '
'; } } } else { } @endphp
Team & Commissions