Skip to content

Commit

Permalink
Merge branch 'main' of github.com:HE-Arc/PokeTeams
Browse files Browse the repository at this point in the history
  • Loading branch information
noa-devv committed Dec 5, 2024
2 parents 88f3fa4 + d70a94c commit 003aa72
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 8 additions & 3 deletions app/Http/Controllers/TeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@

class TeamController extends Controller
{
public function index(): \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory|\Illuminate\Foundation\Application
public function index(Request $request): \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory|\Illuminate\Foundation\Application
{
$teams = Team::all();
return view('teams.index', compact('teams'));
$show_others = !empty($request->input('show-others'));
if ($show_others) {
$teams = Team::all();
} else {
$teams = Team::query()->where('user_id', Auth::id())->get();
}
return view('teams.index', compact('teams', 'show_others'));
}

public function create(): \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory|\Illuminate\Foundation\Application
Expand Down
11 changes: 10 additions & 1 deletion resources/views/teams/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
<i class="bi bi-plus-square-fill"></i> Add new Team
</a>

<form method="get" action="{{ route('teams.index') }}" class="d-flex align-items-center gap-3 mt-3 mb-3">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" role="switch" id="show-other-peoples-teams" name="show-others" onchange="this.form.submit()" @checked($show_others)>
<label for="show-other-peoples-teams">Show other people's teams</label>
</div>
</form>

@if($teams->isEmpty())
<p>No teams found.</p>
@else
Expand Down Expand Up @@ -48,16 +55,18 @@
<a href="{{ route('teams.show', $team->id) }}" class="btn btn-info btn-icon btn-actions">
<i class="bi bi-eye-fill"></i>
</a>
@if($team->user_id == auth()->id())
<a href="{{ route('teams.edit', $queryParams) }}" class="btn btn-warning btn-icon btn-actions">
<i class="bi bi-pencil-fill"></i>
</a>
<form action="{{ route('teams.destroy', $team->id) }}" method="POST">
@csrf
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-icon btn-actions">
<i class="bi bi-trash-fill"></i>
</button>
</form>
@endif
</div>
</div>
</div>
Expand Down

0 comments on commit 003aa72

Please sign in to comment.