Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements and design change #117

Merged
merged 6 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion resources/views/web/home/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class="btn btn-primary btn-sm">{{ __('Browse Tournaments') }}</a>
</div>
</div>

<div class="row mt-3">
<div class="row mt-3 d-none">
<div class="col-lg-12">
<div class="card text-center">
<div class="card-body">
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
Loading