Skip to content

Commit

Permalink
Fix Indentation in UsersController
Browse files Browse the repository at this point in the history
The indentation in the update-function of the UsersController is partially wrong.
Fix this to avoid confusion.
  • Loading branch information
Toreg87 committed Nov 7, 2024
1 parent a41529d commit 2db7037
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions app/Http/Controllers/Users/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,33 +288,31 @@ public function update(SaveUserRequest $request, User $user)
$user->password = bcrypt($request->input('password'));
}


// Update the location of any assets checked out to this user
Asset::where('assigned_type', User::class)
->where('assigned_to', $user->id)
->update(['location_id' => $user->location_id]);

$permissions_array = $request->input('permission');

$permissions_array = $request->input('permission');

// Strip out the superuser permission if the user isn't a superadmin
if (! auth()->user()->isSuperUser()) {
unset($permissions_array['superuser']);
$permissions_array['superuser'] = $orig_superuser;
}
// Strip out the superuser permission if the user isn't a superadmin
if (! auth()->user()->isSuperUser()) {
unset($permissions_array['superuser']);
$permissions_array['superuser'] = $orig_superuser;
}

$user->permissions = json_encode($permissions_array);
$user->permissions = json_encode($permissions_array);

// Handle uploaded avatar
app(ImageUploadRequest::class)->handleImages($user, 600, 'avatar', 'avatars', 'avatar');
session()->put(['redirect_option' => $request->get('redirect_option')]);
// Handle uploaded avatar
app(ImageUploadRequest::class)->handleImages($user, 600, 'avatar', 'avatars', 'avatar');
session()->put(['redirect_option' => $request->get('redirect_option')]);

if ($user->save()) {
// Redirect to the user page
return redirect()->to(Helper::getRedirectOption($request, $user->id, 'Users'))
->with('success', trans('admin/users/message.success.update'));
}
return redirect()->back()->withInput()->withErrors($user->getErrors());
if ($user->save()) {
// Redirect to the user page
return redirect()->to(Helper::getRedirectOption($request, $user->id, 'Users'))
->with('success', trans('admin/users/message.success.update'));
}
return redirect()->back()->withInput()->withErrors($user->getErrors());
}

/**
Expand Down

0 comments on commit 2db7037

Please sign in to comment.