Commit fb586783 authored by Nicolas Widart's avatar Nicolas Widart

Adding roles selection to the create user

parent 0f9c3fdd
...@@ -47,7 +47,9 @@ class UserController extends AdminBaseController ...@@ -47,7 +47,9 @@ class UserController extends AdminBaseController
*/ */
public function create() public function create()
{ {
return View::make('user::admin.users.create'); $roles = $this->roles->all();
return View::make('user::admin.users.create', compact('roles'));
} }
/** /**
...@@ -59,13 +61,12 @@ class UserController extends AdminBaseController ...@@ -59,13 +61,12 @@ class UserController extends AdminBaseController
public function store(CreateUserRequest $request) public function store(CreateUserRequest $request)
{ {
$user = $this->users->create($request->all()); $user = $this->users->create($request->all());
$user->roles()->attach($request->roles);
$code = Activation::create($user); $code = Activation::create($user);
Activation::complete($user, $code); Activation::complete($user, $code);
Flash::success('User created.'); Flash::success('User created.');
return Redirect::route('dashboard.user.index'); return Redirect::route('dashboard.user.index');
} }
......
...@@ -59,6 +59,18 @@ ...@@ -59,6 +59,18 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<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"> <div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">Create</button> <button type="submit" class="btn btn-primary btn-flat">Create</button>
......
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