Skip to content

Commit

Permalink
Merge pull request #117 from AiAe/dev-aiae
Browse files Browse the repository at this point in the history
Improvements and design change
  • Loading branch information
AiAe authored May 14, 2024
2 parents be6437c + 963224d commit 478a527
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 24 deletions.
2 changes: 2 additions & 0 deletions app/Enums/StaffRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum StaffRole: int
case HeadStreamer = 6;
case Streamer = 7;
case Commentator = 8;
case Composer = 9;

public function name(): string
{
Expand All @@ -30,6 +31,7 @@ public function name(): string
self::HeadStreamer => 'Head Streamer',
self::Streamer => 'Streamer',
self::Commentator => 'Commentator',
self::Composer => 'Composer',
};
}
}
9 changes: 8 additions & 1 deletion app/Http/Livewire/Tournaments/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace App\Http\Livewire\Tournaments;

use App\Enums\TournamentStatus;
use App\Enums\UserRoles;
use App\Models\Tournament;
use Illuminate\Database\Eloquent\Builder;
use Livewire\Component;
use Livewire\WithPagination;

Expand Down Expand Up @@ -76,6 +76,13 @@ public function render()

if (stringHasValue($this->status)) {
$tournaments->where('status', $this->status);
} else {
$tournaments->where(function (Builder $query) {
$query->where('status', TournamentStatus::RegistrationsOpen);
$query->orWhere('status', TournamentStatus::Ongoing);
$query->orWhere('status', TournamentStatus::Upcoming);
});

}

$tournaments->with('metas', 'teams', 'teams.members');
Expand Down
8 changes: 8 additions & 0 deletions app/Policies/TournamentPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@
use App\Models\TournamentStageRound;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Support\Facades\Auth;

class TournamentPolicy
{
use HandlesAuthorization;

public function before(): bool|null
{
if(!app()->isProduction() && Auth::user() && Auth::user()->hasRole(UserRoles::Admin)) return true;

return null;
}

public function viewAny(?User $user): bool
{
return true;
Expand Down
63 changes: 40 additions & 23 deletions resources/views/web/tournaments/staff/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@
@endpush

@section('section')
<style>
.table a {
text-decoration: none;
display: inline-block;
}
.table a div {
display: flex;
flex-direction: row;
align-items: center;
gap: 5px;
}
</style>
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<div>{{ $title }}</div>
Expand All @@ -28,36 +41,40 @@ class="btn btn-primary btn-sm">{{ __('Create') }}</a>
<table class="table table-hover table-dark">
<thead>
<tr>
<th style="width: 25%;">{{ __('Role') }}</th>
<th>{{ __('User') }}</th>
@can('update', $tournament)
<th style="width: 20%;">{{ __('Actions') }}</th>
@endcan
<th style="width: 15%;">{{ __('Position') }}</th>
<th>{{ __('Member(s)') }}</th>
</tr>
</thead>
<tbody>
@forelse($tournament->staff as $staff)
@php($staff_enums = \App\Enums\StaffRole::class)
@foreach(\App\Enums\StaffRole::names() as $key => $name)
@php($role = $staff_enums::from($key))
@php($members = collect($tournament->staff)->where('staff_role', $role))
<tr>
<td>{{ $staff->staff_role->name() }}</td>
<td> {{ $role->name() }}</td>
<td>
<a href="{{ $staff->user->quaverUrl() }}" target="_blank" rel="noreferrer">
{{ $staff->user->username }}
</a>
@if(count($members))
@foreach($members as $member)
<a href="{{ $member->user->quaverUrl() }}" target="_blank">
<div>
<img src="{{ countryFlag($member->user->country) }}"
alt="{{ $member->user->country }}" height="14">
{{ $member->user->username }}
</div>
</a>
@can('update', $tournament)
{{ Form::open(['url' => route('web.tournaments.staff.destroy', ['tournament' => $tournament, 'staff' => $member->id]), 'class' => 'd-inline-block']) }}
@method('DELETE')
<a href="#" class="text-danger" onclick="this.closest('form').submit();return false;"><i class="bi bi-x"></i></a>
{{ Form::close() }}
@endcan
@endforeach
@else
-
@endif
</td>
@can('update', $tournament)
<td>
{{ Form::open(['url' => route('web.tournaments.staff.destroy', ['tournament' => $tournament, 'staff' => $staff->id]), 'class' => 'd-flex']) }}
@method('DELETE')
{{ Form::submit(__('Kick'), ['class' => 'btn btn-danger btn-sm']) }}
{{ Form::close() }}
</td>
@endcan
</tr>
@empty
<tr>
<td colspan="2">{{ __('There is currently no Staff') }}</td>
</tr>
@endforelse
@endforeach
</tbody>
</table>
</div>
Expand Down

0 comments on commit 478a527

Please sign in to comment.