Skip to content

Commit

Permalink
fixing applied agents
Browse files Browse the repository at this point in the history
  • Loading branch information
originalaidn committed Nov 29, 2024
1 parent 92e416b commit f9c92b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
12 changes: 5 additions & 7 deletions app/Http/Controllers/WeaponSkinController.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,15 @@ public function agents()

foreach ($agents as &$agent) {
if ($appliedAgents) {
$agent['is_applied_t'] = $agent['team'] == 2 && $agent['model'] == $appliedAgents->agent_t;
$agent['is_applied_ct'] = $agent['team'] == 3 && $agent['model'] == $appliedAgents->agent_ct;
$agent['is_applied'] = ($agent['team'] == 2 && $agent['model'] == $appliedAgents->agent_t) || ($agent['team'] == 3 && $agent['model'] == $appliedAgents->agent_ct);
} else {
$agent['is_applied_t'] = false;
$agent['is_applied_ct'] = false;
$agent['is_applied'] = false;
}
}

// Sort applied agents to be first (T or CT applied)
usort($agents, function ($a, $b) {
return ($b['is_applied_t'] || $b['is_applied_ct']) - ($a['is_applied_t'] || $a['is_applied_ct']);
// Sort applied agents to be first
usort($agents, function($a, $b) {
return $b['is_applied'] - $a['is_applied'];
});

return view('weapons.agents', ['agents' => $agents]);
Expand Down
17 changes: 9 additions & 8 deletions resources/views/weapons/agents.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
<span class="badge badge-warning">T</span>
@endif

<span id="agent_{{$agent['model']}}" class="badge badge-{{ $agent['team'] == 3 ? 'primary' : 'danger' }}">{{ (isset($agent['is_applied_t']) && isset($agent['is_applied_ct']) && $agent['is_applied_t'] && $agent['is_applied_ct'])
? __('skins.active_both')
: (isset($agent['is_applied_t']) && $agent['is_applied_t']
? __('skins.active_t')
: (isset($agent['is_applied_ct']) && $agent['is_applied_ct']
? __('skins.active_ct')
: ''))
}}</span>
@if($agent['is_applied'])
<span id="agent_{{$agent['model']}}" class="badge badge-{{ $agent['team'] == 3 ? 'primary' : 'danger' }}">
@if($agent['team'] == 2)
{{ __('skins.active_t') }}
@elseif($agent['team'] == 3)
{{ __('skins.active_ct') }}
@endif
</span>
@endif
<div class="loader-skins"></div> <!-- Add loader -->
<img src="{{ $agent['image'] }}" class="card-img-top" alt="{{ $agent['agent_name'] }}" crossorigin="anonymous">
</a>
Expand Down

0 comments on commit f9c92b3

Please sign in to comment.