diff --git a/app/Console/Commands/NormalizeUserNames.php b/app/Console/Commands/NormalizeUserNames.php new file mode 100644 index 0000000000..c3ea5e8ace --- /dev/null +++ b/app/Console/Commands/NormalizeUserNames.php @@ -0,0 +1,52 @@ +info($users->count() . ' users'); + + foreach ($users as $user) { + $user->first_name = ucwords(strtolower($user->first_name)); + $user->last_name = ucwords(strtolower($user->last_name)); + $user->email = strtolower($user->email); + $user->save(); + } + } +} diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 6bd6d1d090..ff18b87910 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -192,7 +192,6 @@ class UsersController extends Controller } $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; - $offset = (($users) && (request('offset') > $users->count())) ? 0 : request('offset', 0); // Set the offset to the API call's offset, unless the offset is higher than the actual count of items in which // case we override with the actual count, so we should return 0 items. @@ -218,6 +217,14 @@ class UsersController extends Controller case 'company': $users = $users->OrderCompany($order); break; + case 'first_name': + $users->orderBy('first_name', $order); + $users->orderBy('last_name', $order); + break; + case 'last_name': + $users->orderBy('last_name', $order); + $users->orderBy('first_name', $order); + break; default: $allowed_columns = [ diff --git a/app/Http/Controllers/Licenses/LicenseFilesController.php b/app/Http/Controllers/Licenses/LicenseFilesController.php index db414edebf..d457d4983a 100644 --- a/app/Http/Controllers/Licenses/LicenseFilesController.php +++ b/app/Http/Controllers/Licenses/LicenseFilesController.php @@ -91,29 +91,30 @@ class LicenseFilesController extends Controller */ public function destroy($licenseId = null, $fileId = null) { - $license = License::find($licenseId); + if ($license = License::find($licenseId)) { - // the asset is valid - if (isset($license->id)) { $this->authorize('update', $license); - $log = Actionlog::find($fileId); - // Remove the file if one exists - if (Storage::exists('licenses/'.$log->filename)) { - try { - Storage::delete('licenses/'.$log->filename); - } catch (\Exception $e) { - \Log::debug($e); + if ($log = Actionlog::find($fileId)) { + + // Remove the file if one exists + if (Storage::exists('licenses/'.$log->filename)) { + try { + Storage::delete('licenses/'.$log->filename); + } catch (\Exception $e) { + \Log::debug($e); + } } + + $log->delete(); + + return redirect()->back() + ->with('success', trans('admin/hardware/message.deletefile.success')); } - $log->delete(); - - return redirect()->back() - ->with('success', trans('admin/hardware/message.deletefile.success')); + return redirect()->route('licenses.index')->with('error', trans('general.log_does_not_exist')); } - // Redirect to the licence management page return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.does_not_exist')); } @@ -129,7 +130,6 @@ class LicenseFilesController extends Controller */ public function show($licenseId = null, $fileId = null, $download = true) { - \Log::info('Private filesystem is: '.config('filesystems.default')); $license = License::find($licenseId); // the license is valid diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 97be38f509..8ac322e8b8 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -407,7 +407,7 @@ return [ 'true' => 'True', 'false' => 'False', 'integration_option' => 'Integration Option', - + 'log_does_not_exist' => 'No matching log record exists.', ]; \ No newline at end of file