Browse Source

admin role for editing teams

master
Aaron Parecki 7 years ago
parent
commit
06473c6263
No known key found for this signature in database GPG Key ID: 276C2817346D6056
4 changed files with 14 additions and 9 deletions
  1. +4
    -5
      app/Http/Controllers/TeamController.php
  2. +4
    -1
      resources/views/layouts/app.blade.php
  3. +6
    -2
      resources/views/teams.blade.php
  4. +0
    -1
      routes/web.php

+ 4
- 5
app/Http/Controllers/TeamController.php View File

@ -61,6 +61,8 @@ class TeamController extends Controller
public function create_team()
{
$this->authorize('admin');
// Get list of current used colors
$teams = DB::table('teams')->pluck('name')->toArray();
$color_names = array_values(self::colors());
@ -84,6 +86,8 @@ class TeamController extends Controller
public function add_player(Request $request)
{
$this->authorize('admin');
try {
// Look up the user ID
$profile = Twitter::getUsers(['screen_name' => trim($request->input('twitter'), '@')]);
@ -107,9 +111,4 @@ class TeamController extends Controller
return response()->json(['error'=>$e->getMessage()]);
}
}
public function remove_player()
{
}
}

+ 4
- 1
resources/views/layouts/app.blade.php View File

@ -36,7 +36,10 @@
<div class="collapse navbar-collapse" id="app-navbar-collapse">
<!-- Left Side Of Navbar -->
<ul class="nav navbar-nav">
<li><a href="{{ route('teams') }}">Teams</a></li>
<li><a href="{{ route('home') }}">Dashboard</a></li>
@can('admin')
<li><a href="{{ route('teams') }}">Teams</a></li>
@endcan
<li><a href="{{ route('scoreboard') }}">Scoreboard</a></li>
</ul>

+ 6
- 2
resources/views/teams.blade.php View File

@ -30,16 +30,19 @@
@endforeach
</ul>
@can('admin')
<form class="form-inline">
<div class="form-group">
<input type="text" class="form-control new-player-twitter" data-team="{{ $team->id }}" placeholder="@twitter">
<button type="submit" class="btn btn-default new-player-twitter-btn">Add</button>
</div>
</form>
</form>
@endcan
</div>
</section>
@endforeach
@can('admin')
<button id="add-team" class="btn btn-default">New Team</button>
<br><br>
@ -49,7 +52,8 @@
<input type="text" class="form-control new-player-twitter" data-team="0" placeholder="@twitter">
<button type="submit" class="btn btn-default new-player-twitter-btn">Remove</button>
</div>
</form>
</form>
@endcan
</div>
</div>

+ 0
- 1
routes/web.php View File

@ -22,7 +22,6 @@ Route::get('/home', 'HomeController@index')->name('home');
Route::get('/teams', 'TeamController@index')->name('teams');
Route::post('/teams/new', 'TeamController@create_team');
Route::post('/teams/add-player', 'TeamController@add_player');
Route::post('/teams/remove-player', 'TeamController@remove_player');
Route::get('/scoreboard', 'ScoreboardController@index')->name('scoreboard');

Loading…
Cancel
Save