Commit b01df84f authored by Nicolas Widart's avatar Nicolas Widart

Adding a roles index view

parent 3f97fadf
......@@ -22,7 +22,7 @@ class SidebarViewComposer
],
[
'request' => "{$view->prefix}/messages/roles",
'route' => 'dashboard.user.index',
'route' => 'dashboard.role.index',
'icon-class' => 'fa fa-flag-o',
'title' => 'Roles',
]
......
<?php namespace Modules\User\Http\Controllers\Admin;
use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
use Illuminate\Support\Facades\View;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
class RolesController extends AdminBaseController
{
protected $roles;
public function __construct()
{
parent::__construct();
$this->roles = Sentinel::getRoleRepository()->createModel();
}
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$roles = $this->roles->all();
return View::make('user::admin.roles.index', compact('roles'));
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
return \View::make('user::admin.roles.create');
}
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
return \View::make('user::admin.roles.show');
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
return \View::make('user::admin.roles.edit');
}
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}
\ No newline at end of file
......@@ -10,4 +10,12 @@ Route::group(['prefix' => Config::get('core::core.admin-prefix'), 'namespace' =>
'update' => 'dashboard.user.update',
'destroy' => 'dashboard.user.destroy',
]]);
Route::resource('users', 'Admin\RolesController', ['except' => ['show'], 'names' => [
'index' => 'dashboard.role.index',
'create' => 'dashboard.role.create',
'store' => 'dashboard.role.store',
'edit' => 'dashboard.role.edit',
'update' => 'dashboard.role.update',
'destroy' => 'dashboard.role.destroy',
]]);
});
\ No newline at end of file
@extends('core::layouts.master')
@section('content-header')
<h1>
New Role
</h1>
<ol class="breadcrumb">
<li><a href="{{ URL::route('dashboard.index') }}"><i class="fa fa-dashboard"></i> Home</a></li>
<li class=""><a href="{{ URL::route('dashboard.user.index') }}">Users</a></li>
<li class="active">New</li>
</ol>
@stop
@section('content')
<div class="row">
<div class="col-md-12">
<div class="box box-<?php echo $errors->first() ? 'danger' : 'info'; ?>">
{!! Form::open(['route' => 'dashboard.user.store', 'method' => 'post']) !!}
<div class="box-body">
<div class="row">
@include('flash::message')
</div>
<div class="row">
<div class="col-sm-4">
<div class="form-group{{ $errors->has('first_name') ? ' has-error' : '' }}">
{!! Form::label('first_name', 'First name:') !!}
{!! Form::text('first_name', Input::old('first_name'), ['class' => 'form-control', 'placeholder' => 'First name']) !!}
{!! $errors->first('first_name', '<span class="help-block">:message</span>') !!}
</div>
</div>
<div class="col-sm-4">
<div class="form-group{{ $errors->has('last_name') ? ' has-error' : '' }}">
{!! Form::label('last_name', 'Last name:') !!}
{!! Form::text('last_name', Input::old('last_name'), ['class' => 'form-control', 'placeholder' => 'Last name']) !!}
{!! $errors->first('last_name', '<span class="help-block">:message</span>') !!}
</div>
</div>
<div class="col-sm-4">
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
{!! Form::label('email', 'Email:') !!}
{!! Form::email('email', Input::old('email'), ['class' => 'form-control', 'placeholder' => 'Email address']) !!}
{!! $errors->first('email', '<span class="help-block">:message</span>') !!}
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
{!! Form::label('password', 'Password:') !!}
{!! Form::password('password', ['class' => 'form-control']) !!}
{!! $errors->first('password', '<span class="help-block">:message</span>') !!}
</div>
</div>
<div class="col-sm-6">
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
{!! Form::label('password_confirmation', 'Password confirmation:') !!}
{!! Form::password('password_confirmation', ['class' => 'form-control']) !!}
{!! $errors->first('password_confirmation', '<span class="help-block">:message</span>') !!}
</div>
</div>
</div>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">Create</button>
<a class="btn btn-danger pull-right btn-flat" href="{{ URL::route('dashboard.user.index')}}"><i class="fa fa-times"></i> Cancel</a>
</div>
{!! Form::close() !!}
</div>
</div>
</div>
@stop
@extends('core::layouts.master')
@section('content-header')
<h1>
Roles
</h1>
<ol class="breadcrumb">
<li><a href="{{ URL::route('dashboard.index') }}"><i class="fa fa-dashboard"></i> Home</a></li>
<li class="active">Roles</li>
</ol>
@stop
@section('content')
<div class="row">
<div class="col-xs-12">
<div class="row">
@include('flash::message')
<div class="btn-group pull-right" style="margin: 0 15px 15px 0;">
<a href="{{ URL::route('dashboard.role.create') }}" class="btn btn-primary btn-flat" style="padding: 4px 10px;">
<i class="fa fa-pencil"></i> New Role
</a>
</div>
</div>
<div class="box">
<div class="box-header">
</div>
<!-- /.box-header -->
<div class="box-body table-responsive">
<table class="data-table table table-bordered table-hover">
<thead>
<tr>
<th>Created at</th>
<th>Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php if ($roles->count() > 0): ?>
<?php foreach($roles as $role): ?>
<tr>
<td>
<a href="{{ URL::route('dashboard.role.edit', [$role->id]) }}">
{{ $role->created_at }}
</a>
</td>
<td>
<a href="{{ URL::route('dashboard.role.edit', [$role->id]) }}">
{{ $role->name }}
</a>
</td>
<td>
<div class="btn-group">
<a href="{{ URL::route('dashboard.role.edit', [$role->id]) }}" class="btn btn-default btn-flat"><i class="glyphicon glyphicon-pencil"></i></a>
<button class="btn btn-danger btn-flat" data-toggle="modal" data-target="#confirmation-{{ $role->id }}"><i class="glyphicon glyphicon-trash"></i></button>
</div>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
<tfoot>
<tr>
<th>Created at</th>
<th>Name</th>
<th>Actions</th>
</tr>
</tfoot>
</table>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
<!-- /.col (MAIN) -->
</div>
</div>
<?php if ($roles->count() > 0): ?>
<?php foreach($roles as $role): ?>
<!-- Modal -->
<div class="modal fade" id="confirmation-{{ $role->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.role.destroy', $role->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')
<script type="text/javascript">
$(function () {
$('.data-table').dataTable({
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bInfo": true,
"bAutoWidth": true,
"aoColumns": [
null,
null,
{ "bSortable": false }
]
});
});
</script>
@stop
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