Skip to content

Commit

Permalink
Added simpe admin page
Browse files Browse the repository at this point in the history
  • Loading branch information
canvasowl committed Sep 15, 2016
1 parent 89f05b0 commit 2beb02c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ MAIL_ENCRYPTION=null
MAIL_FROM=[email protected]
MAIL_FROM_NAME=Project Administrator

ADMIN_EMAIL=[email protected]

GOOGLE_UA=
USERVOICE_URL=
19 changes: 19 additions & 0 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
<?php

namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;

use App\User;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;

class AdminController extends BaseController {

/**
* Takes you to the admin page of the app
* @return mixed
*/
public function index(){
if( Auth::user()->email != env('ADMIN_EMAIL') ){
return Redirect::back();
}

$users = User::all();
$n = count($users);
return View::make('admin/index')->with('pTitle', 'Admin')->with('users', $users)->with('n', $n);
}

}
1 change: 1 addition & 0 deletions app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@
});

//----------------- Admin routes
Route::get('admin','AdminController@index');
28 changes: 28 additions & 0 deletions resources/views/admin/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@extends('templates/ins/master')

@section('content')

<div class="row">
<div class="col-xs-12">
<h1>Admin</h1>
<p>Number of users: <span class="badge">{{ $n }}</span></p>
<table class="table table-striped">
<thead>
<tr>
<th>Full Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
<tr>
<td>{{ $user->full_name }}</td>
<td>{{ $user->email }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>

@stop()

0 comments on commit 2beb02c

Please sign in to comment.