This commit is contained in:
sidya82 2015-02-17 22:20:17 +01:00
commit c277b5678d
14 changed files with 93 additions and 27 deletions

View File

@ -68,3 +68,15 @@ git pull
exit exit
git pull git pull
exit exit
git pull
git status
git add .
git commit -m "admin view & navbar_signed"
git push
git pull
exit
git pull
exit
cd ..
ls
nano loadCSVAugustin2014.py

View File

@ -1,6 +1,7 @@
<?php namespace App\Http\Controllers; <?php namespace App\Http\Controllers;
use App\User; use App\User;
use Input;
class AdminController extends Controller { class AdminController extends Controller {
@ -34,11 +35,30 @@ class AdminController extends Controller {
*/ */
public function addUser() public function addUser()
{ {
$firstname = Request::input('firstname'); $user = new User;
$lastname = Input::get('lastname');
$email = Input::get('email'); $user->firstname = Input::get('firstname');
$city = Input::get('city'); $user->email = Input::get('email');
//print('ok'); $user->admin = 0;
$user->city = Input::get('city');
$user->lastname = Input::get('lastname');
$user->image = "pictures/user_picture/default.png";
$user->save();
return redirect('/admin')->with('message_add', 'Referent ajouté avec succès');
}
/**
* Delete an user
*
*/
public function deleteUser()
{
$idUser = Input::get('idUser');
$user = User::find($idUser);
$user->delete();
return redirect('/admin')->with('message_delete', 'Referent supprimé avec succès');
} }
} }

View File

@ -35,7 +35,7 @@ class RedirectIfNotAdmin {
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
if (!$this->auth->check() OR Auth::user()->admin == 0) if (!$this->auth->check() OR Auth::user()->droit == 0)
{ {
return new RedirectResponse(url('/login')); return new RedirectResponse(url('/login'));
} }

View File

@ -33,5 +33,5 @@ Route::group(['middleware' => 'admin'], function ()
{ {
Route::get('admin', 'AdminController@index'); Route::get('admin', 'AdminController@index');
Route::post('addUser', 'AdminController@addUser'); Route::post('addUser', 'AdminController@addUser');
Route::post('deleteUser', 'AdminController@deleteUser');
}); });

View File

@ -27,10 +27,12 @@ class UserTableSeeder extends Seeder {
//DB::table('users')->truncate(); //DB::table('users')->truncate();
$user = array( $user = array(
'name' => 'admin', 'firstname' => 'admin',
'lastname' => 'admin',
'city' => 'Montauban',
'email' => 'admin@admin.com', 'email' => 'admin@admin.com',
'password' => Hash::make('admin'), 'password' => Hash::make('admin'),
'image' => '', 'image' => 'pictures/user_picture/default.png',
'admin' => '1' 'admin' => '1'
); );
@ -38,10 +40,12 @@ class UserTableSeeder extends Seeder {
DB::table('users')->insert($user); DB::table('users')->insert($user);
$user = array( $user = array(
'name' => 'ref', 'lastname' => 'ref',
'firstname' => 'ref',
'city' => 'Toulouse',
'email' => 'ref@ref.com', 'email' => 'ref@ref.com',
'password' => Hash::make('ref'), 'password' => Hash::make('ref'),
'image' => '', 'image' => 'pictures/user_picture/default.png',
'admin' => '0' 'admin' => '0'
); );

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -2,6 +2,9 @@
@section('content') @section('content')
{{ Session::get('message_add') }}
{{ Session::get('message_delete') }}
<br> <br>
<div class="col-md-2"></div> <div class="col-md-2"></div>
@ -12,21 +15,33 @@
<thead> <thead>
<tr style="background-color: #F7BE81"> <tr style="background-color: #F7BE81">
<td>Nom</td> <td>Nom</td>
<td>Prénom</td>
<td>Mail</td> <td>Mail</td>
<td>Lieu</td> <td>Lieu</td>
<td>Type</td>
<td>Se connecter</td> <td>Se connecter</td>
<td>Supprimer</td> <td>Supprimer</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach ($users as $user) @foreach ($users as $user)
<form method="POST" role="form" action="deleteUser">
<input type="hidden" name="idUser" value="{{ $user->id }}">
<input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
<tr style="background-color: #F6E3CE"> <tr style="background-color: #F6E3CE">
<td>{{$user->name}}</td> <td>{{$user->firstname}}</td>
<td>{{$user->lastname}}</td>
<td>{{$user->email}}</td> <td>{{$user->email}}</td>
<td>Toulouse</td> <td>{{$user->city}}</td>
<td><a href="#" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-ok"></span></a></td> @if ($user->admin == 0)
<td><a href="#" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash"></span></a></td> <td>Référent</td>
@else
<td>Admin</td>
@endif
<td><a href="#" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-log-in"></span></a></td>
<td><button type="submit" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash"></span></a></td>
</tr> </tr>
</form>
@endforeach @endforeach
</tbody> </tbody>
</table> </table>
@ -42,37 +57,45 @@
<h4 class="modal-title" id="myModalLabel">Créer un nouvel adhérent</h4> <h4 class="modal-title" id="myModalLabel">Créer un nouvel adhérent</h4>
</div> </div>
<form class="form-horizontal" method="POST" role="form" action="addUser"> <form class="form-horizontal" method="POST" role="form" action="addUser">
<input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
<div class="modal-body"> <div class="modal-body">
<div class="form-group"> <div class="form-group">
<label for="firstname" class="col-sm-2 control-label">Prénom</label> <label for="firstname" class="col-sm-2 control-label">Prénom</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" class="form-control" id="firstname" name="firstname" placeholder="Prénom"> <input type="text" class="form-control" id="firstname" name="firstname" required placeholder="Prénom">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="lastname" class="col-sm-2 control-label">Nom</label> <label for="lastname" class="col-sm-2 control-label">Nom</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" class="form-control" id="lastname" placeholder="Nom"> <input type="text" class="form-control" id="lastname" name="lastname" required placeholder="Nom">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="email" class="col-sm-2 control-label">Email</label> <label for="email" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="email" class="form-control" id="email" placeholder="Email"> <input type="email" class="form-control" id="email" name="email" required placeholder="Email">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="city" class="col-sm-2 control-label">Ville</label> <label for="city" class="col-sm-2 control-label">Ville</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" class="form-control" id="city" placeholder="Ville"> <input type="text" class="form-control" id="city" name="city" required placeholder="Ville">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label>
<input name="isadmin" type="checkbox"> Est administrateur
</label>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button> <button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button>
<button type="button" class="btn btn-primary">Enregistrer</button> <button type="submit" class="btn btn-primary">Enregistrer</button>
</div> </div>
</form> </form>
</div> </div>

View File

@ -1,12 +1,19 @@
<nav class="navbar navbar-default"> <nav class="navbar navbar-default">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="#">Espace {{ $nameRoute }}</a> <a class="navbar-brand" href="#">Espace {{ $nameRoute }}</a>
<!-- <span class="glyphicon glyphicon-user" aria-hidden="true"></span> --> <p class="navbar-text"><img height="25" weight="25" src="{{$me->image}}"></img> </p>
<p class="navbar-text"><img height="50" weight="50" src="{{$me->image}}"></img> </p> <p class="navbar-text">{{$me->firstname}}</p>
<p class="navbar-text">{{$me->name}}</p> <p class="navbar-text">{{$me->lastname}}</p>
<p class="navbar-text">{{$me->email}}</p> <p class="navbar-text">{{$me->email}}</p>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li><a href="logout">Se déconnecter</a></li> <li>
<a href="logout">Se déconnecter</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="">Mes paramètres</a>
</li>
</ul> </ul>
</div> </div>
</nav> </nav>