public function update($id)
{
// Get the Role Model instance.
$role = Role::find($id);
if ($role === null) {
// There is no Role with this ID.
$status = __d('users', 'Role not found: #{0}', $id);
return Redirect::to('admin/roles')->withStatus($status, 'danger');
}
// Validate the Input data.
$input = Input::only('name', 'slug', 'description');
$validator = $this->validate($input, $id);
if ($validator->passes()) {
$origName = $role->name;
// Update the Role Model instance.
$role->name = $input['name'];
$role->slug = $input['slug'];
$role->description = $input['description'];
// Save the Role information.
$role->save();
// Prepare the flash message.
$status = __d('users', 'The Role <b>{0}</b> was successfully updated.', $origName);
return Redirect::to('admin/roles')->withStatus($status);
}
// Errors occurred on Validation.
$status = $validator->errors();
return Redirect::back()->withInput()->withStatus($status, 'danger');
}