Commit a2e45c80 authored by Nicolas Widart's avatar Nicolas Widart

Adding permissions to the user create view

parent 32d1da3b
...@@ -69,7 +69,8 @@ class UserController extends AdminBaseController ...@@ -69,7 +69,8 @@ class UserController extends AdminBaseController
*/ */
public function store(CreateUserRequest $request) public function store(CreateUserRequest $request)
{ {
$user = $this->users->create($request->all()); $data = array_merge($request->all(), ['permissions' => $this->permissions->clean($request->permissions)]);
$user = $this->users->create($data);
$user->roles()->attach($request->roles); $user->roles()->attach($request->roles);
$code = Activation::create($user); $code = Activation::create($user);
......
...@@ -11,73 +11,107 @@ ...@@ -11,73 +11,107 @@
</ol> </ol>
@stop @stop
@section('styles')
<link href="{{{ core_asset('css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
@stop
@section('content') @section('content')
{!! Form::open(['route' => 'dashboard.user.store', 'method' => 'post']) !!}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="box box-<?php echo $errors->first() ? 'danger' : 'info'; ?>"> <div class="nav-tabs-custom">
{!! Form::open(['route' => 'dashboard.user.store', 'method' => 'post']) !!} <ul class="nav nav-tabs">
<div class="box-body"> <li class="active"><a href="#tab_1-1" data-toggle="tab">Data</a></li>
<div class="row"> <li class=""><a href="#tab_2-2" data-toggle="tab">Roles</a></li>
@include('flash::message') <li class=""><a href="#tab_3-3" data-toggle="tab">Permissions</a></li>
</div> </ul>
<div class="row"> <div class="tab-content">
<div class="col-sm-4"> <div class="tab-pane active" id="tab_1-1">
<div class="form-group{{ $errors->has('first_name') ? ' has-error' : '' }}"> <div class="box-body">
{!! Form::label('first_name', 'First name:') !!} <div class="row">
{!! Form::text('first_name', Input::old('first_name'), ['class' => 'form-control', 'placeholder' => 'First name']) !!} @include('flash::message')
{!! $errors->first('first_name', '<span class="help-block">:message</span>') !!}
</div> </div>
</div> <div class="row">
<div class="col-sm-4"> <div class="col-sm-4">
<div class="form-group{{ $errors->has('last_name') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('first_name') ? ' has-error' : '' }}">
{!! Form::label('last_name', 'Last name:') !!} {!! Form::label('first_name', 'First name:') !!}
{!! Form::text('last_name', Input::old('last_name'), ['class' => 'form-control', 'placeholder' => 'Last name']) !!} {!! Form::text('first_name', Input::old('first_name'), ['class' => 'form-control', 'placeholder' => 'First name']) !!}
{!! $errors->first('last_name', '<span class="help-block">:message</span>') !!} {!! $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>
</div> <div class="row">
<div class="col-sm-4"> <div class="col-sm-6">
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
{!! Form::label('email', 'Email:') !!} {!! Form::label('password', 'Password:') !!}
{!! Form::email('email', Input::old('email'), ['class' => 'form-control', 'placeholder' => 'Email address']) !!} {!! Form::password('password', ['class' => 'form-control']) !!}
{!! $errors->first('email', '<span class="help-block">:message</span>') !!} {!! $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> </div>
</div> </div>
<div class="row"> <div class="tab-pane" id="tab_2-2">
<div class="col-sm-6"> <div class="box-body">
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}"> <div class="row">
{!! Form::label('password', 'Password:') !!} <div class="col-md-6">
{!! Form::password('password', ['class' => 'form-control']) !!} <div class="form-group">
{!! $errors->first('password', '<span class="help-block">:message</span>') !!} <label>Role(s)</label>
</div> <select multiple="" class="form-control" name="roles[]">
</div> <?php foreach($roles as $role): ?>
<div class="col-sm-6"> <option value="{{ $role->id }}">{{ $role->name }}</option>
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}"> <?php endforeach; ?>
{!! Form::label('password_confirmation', 'Password confirmation:') !!} </select>
{!! Form::password('password_confirmation', ['class' => 'form-control']) !!} </div>
{!! $errors->first('password_confirmation', '<span class="help-block">:message</span>') !!} </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="tab-pane" id="tab_3-3">
<div class="col-md-6"> <div class="box-body">
<div class="form-group"> @include('user::admin.users.partials.permissions-create')
<label>Role(s)</label>
<select multiple="" class="form-control" name="roles[]">
<?php foreach($roles as $role): ?>
<option value="{{ $role->id }}">{{ $role->name }}</option>
<?php endforeach; ?>
</select>
</div>
</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>
</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> </div>
</div> </div>
{!! Form::close() !!}
@stop @stop
@section('scripts')
<script>
$( document ).ready(function() {
$('input[type="checkbox"].flat-blue, input[type="radio"].flat-blue').iCheck({
checkboxClass: 'icheckbox_flat-blue',
radioClass: 'iradio_flat-blue'
});
});
</script>
@stop
\ No newline at end of file
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