Skip to content

Commit

Permalink
fixed #97
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Dec 2, 2017
1 parent 4f61d1c commit 1cdbf0a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/Http/Controllers/Auth/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public function index()
*/
public function create()
{
$roles = Role::all();
$roles = Role::all()->reject(function($r) {
return $r->hasPermission('read-customer-panel');
});

$companies = Auth::user()->companies()->get()->sortBy('name');
foreach ($companies as $company) {
Expand Down Expand Up @@ -84,7 +86,17 @@ public function store(Request $request)
*/
public function edit(User $user)
{
$roles = Role::all();
if ($user->customer) {
// Show only roles with customer permission
$roles = Role::all()->reject(function($r) {
return !$r->hasPermission('read-customer-panel');
});
} else {
// Don't show roles with customer permission
$roles = Role::all()->reject(function($r) {
return $r->hasPermission('read-customer-panel');
});
}

$companies = Auth::user()->companies()->get()->sortBy('name');
foreach ($companies as $company) {
Expand Down

0 comments on commit 1cdbf0a

Please sign in to comment.