delete user

This commit is contained in:
Malibu 2015-02-17 21:57:41 +01:00
parent 4a5dbde1c9
commit 75548c78f2
10 changed files with 27 additions and 13 deletions

View File

@ -42,10 +42,10 @@ class AdminController extends Controller {
$user->admin = 0; $user->admin = 0;
$user->city = Input::get('city'); $user->city = Input::get('city');
$user->lastname = Input::get('lastname'); $user->lastname = Input::get('lastname');
$user->image = "./public/pictures/user_picture/default.png"; $user->image = "pictures/user_picture/default.png";
$user->save(); $user->save();
return redirect('/admin')->with('message', 'Referent ajouté avec succès'); return redirect('/admin')->with('message_add', 'Referent ajouté avec succès');
} }
@ -55,7 +55,10 @@ class AdminController extends Controller {
*/ */
public function deleteUser() public function deleteUser()
{ {
// TODO $idUser = Input::get('idUser');
$user = User::find($idUser);
$user->delete();
return redirect('/admin');
} }
} }

View File

@ -32,7 +32,7 @@ class UserTableSeeder extends Seeder {
'city' => 'Montauban', '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'
); );
@ -45,7 +45,7 @@ class UserTableSeeder extends Seeder {
'city' => 'Toulouse', '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

View File

@ -2,7 +2,8 @@
@section('content') @section('content')
{{ Session::get('message') }} {{ Session::get('message_add') }}
{{ Session::get('message_delete') }}
<br> <br>
<div class="col-md-2"></div> <div class="col-md-2"></div>
@ -24,6 +25,9 @@
</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->lastname}}</td> <td>{{$user->lastname}}</td>
<td>{{$user->firstname}}</td> <td>{{$user->firstname}}</td>
@ -35,8 +39,9 @@
<td>Admin</td> <td>Admin</td>
@endif @endif
<td><a href="#" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-ok"></span></a></td> <td><a href="#" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-ok"></span></a></td>
<td><a href="#" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash"></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>
@ -57,25 +62,25 @@
<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" name="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" name="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" name="city" placeholder="Ville"> <input type="text" class="form-control" id="city" name="city" required placeholder="Ville">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -1,13 +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="25" weight="25" src="{{$me->image}}"></img> </p>
<p class="navbar-text">{{$me->firstname}}</p> <p class="navbar-text">{{$me->firstname}}</p>
<p class="navbar-text">{{$me->lastname}}</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>