Commit 94c6a3f5 authored by Nicolas Widart's avatar Nicolas Widart

Adding user delete method

parent 0eb211bc
......@@ -84,6 +84,7 @@ class UserController extends AdminBaseController
public function edit($id)
{
if (!$user = $this->users->createModel()->find($id)) {
Flash::error('User not found');
return Redirect::route('dashboard.user.index');
}
......@@ -116,7 +117,18 @@ class UserController extends AdminBaseController
*/
public function destroy($id)
{
//
if ($user = $this->users->createModel()->find($id))
{
$user->delete();
Flash::success('User deleted');
return Redirect::to('users');
}
Flash::error('User not found');
return Redirect::to('users');
}
}
\ No newline at end of file
......@@ -87,6 +87,31 @@
<!-- /.col (MAIN) -->
</div>
</div>
<?php if ($users->count() > 0): ?>
<?php foreach($users as $user): ?>
<!-- Modal -->
<div class="modal fade" id="confirmation-{{ $user->id }}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Confirmation</h4>
</div>
<div class="modal-body">
Are you sure you want to delete this record?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
{!! Form::open(['route' => ['dashboard.user.destroy', $user->id], 'method' => 'delete', 'class' => 'pull-left']) !!}
<button type="submit" class="btn btn-danger btn-flat"><i class="glyphicon glyphicon-trash"></i> Delete</button>
{!! Form::close() !!}
</div>
</div>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
@stop
@section('scripts')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment