diff --git a/app/Http/Controllers/TeamController.php b/app/Http/Controllers/TeamController.php index c7b6a8e..9eb9e2d 100755 --- a/app/Http/Controllers/TeamController.php +++ b/app/Http/Controllers/TeamController.php @@ -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 diff --git a/resources/views/teams/index.blade.php b/resources/views/teams/index.blade.php index 048da91..fba7925 100755 --- a/resources/views/teams/index.blade.php +++ b/resources/views/teams/index.blade.php @@ -9,6 +9,13 @@ Add new Team +
+
+ + +
+
+ @if($teams->isEmpty())

No teams found.

@else @@ -48,16 +55,18 @@ + @if($team->user_id == auth()->id())
- @csrf + @csrf @method('DELETE')
+ @endif