diff --git a/app/Http/Controllers/Api/AssetMaintenancesController.php b/app/Http/Controllers/Api/AssetMaintenancesController.php index ab94fa4bc2..d73de5c2f2 100644 --- a/app/Http/Controllers/Api/AssetMaintenancesController.php +++ b/app/Http/Controllers/Api/AssetMaintenancesController.php @@ -128,7 +128,7 @@ class AssetMaintenancesController extends Controller // create a new model instance $maintenance = new AssetMaintenance(); $maintenance->fill($request->all()); - $maintenance->created_by = Auth::id(); + $maintenance->created_by = auth()->id(); // Was the asset maintenance created? if ($maintenance->save()) { diff --git a/app/Http/Controllers/Components/ComponentsController.php b/app/Http/Controllers/Components/ComponentsController.php index e216aacb90..430984767e 100644 --- a/app/Http/Controllers/Components/ComponentsController.php +++ b/app/Http/Controllers/Components/ComponentsController.php @@ -81,7 +81,7 @@ class ComponentsController extends Controller $component->purchase_date = $request->input('purchase_date', null); $component->purchase_cost = $request->input('purchase_cost', null); $component->qty = $request->input('qty'); - $component->created_by = Auth::id(); + $component->created_by = auth()->id(); $component->notes = $request->input('notes'); $component = $request->handleImages($component); diff --git a/app/Http/Controllers/Consumables/ConsumablesController.php b/app/Http/Controllers/Consumables/ConsumablesController.php index ee3f0081c2..98141f2783 100644 --- a/app/Http/Controllers/Consumables/ConsumablesController.php +++ b/app/Http/Controllers/Consumables/ConsumablesController.php @@ -81,7 +81,7 @@ class ConsumablesController extends Controller $consumable->purchase_date = $request->input('purchase_date'); $consumable->purchase_cost = $request->input('purchase_cost'); $consumable->qty = $request->input('qty'); - $consumable->created_by = Auth::id(); + $consumable->created_by = auth()->id(); $consumable->notes = $request->input('notes'); diff --git a/app/Http/Controllers/CustomFieldsController.php b/app/Http/Controllers/CustomFieldsController.php index 057b4560d0..5a0dc6aec2 100644 --- a/app/Http/Controllers/CustomFieldsController.php +++ b/app/Http/Controllers/CustomFieldsController.php @@ -104,7 +104,7 @@ class CustomFieldsController extends Controller "auto_add_to_fieldsets" => $request->get("auto_add_to_fieldsets", 0), "show_in_listview" => $request->get("show_in_listview", 0), "show_in_requestable_list" => $request->get("show_in_requestable_list", 0), - "user_id" => Auth::id() + "user_id" => auth()->id() ]); @@ -248,7 +248,7 @@ class CustomFieldsController extends Controller $field->name = trim(e($request->get("name"))); $field->element = e($request->get("element")); $field->field_values = $request->get("field_values"); - $field->created_by = Auth::id(); + $field->created_by = auth()->id(); $field->help_text = $request->get("help_text"); $field->show_in_email = $show_in_email; $field->is_unique = $request->get("is_unique", 0); diff --git a/app/Http/Controllers/Licenses/LicensesController.php b/app/Http/Controllers/Licenses/LicensesController.php index f1245df621..6098423ba3 100755 --- a/app/Http/Controllers/Licenses/LicensesController.php +++ b/app/Http/Controllers/Licenses/LicensesController.php @@ -99,7 +99,7 @@ class LicensesController extends Controller $license->supplier_id = $request->input('supplier_id'); $license->category_id = $request->input('category_id'); $license->termination_date = $request->input('termination_date'); - $license->created_by = Auth::id(); + $license->created_by = auth()->id(); $license->min_amt = $request->input('min_amt'); session()->put(['redirect_option' => $request->get('redirect_option')]); diff --git a/app/Http/Controllers/Users/BulkUsersController.php b/app/Http/Controllers/Users/BulkUsersController.php index 20762e8010..d13f904419 100644 --- a/app/Http/Controllers/Users/BulkUsersController.php +++ b/app/Http/Controllers/Users/BulkUsersController.php @@ -101,7 +101,7 @@ class BulkUsersController extends Controller $user_raw_array = $request->input('ids'); // Remove the user from any updates. - $user_raw_array = array_diff($user_raw_array, [Auth::id()]); + $user_raw_array = array_diff($user_raw_array, [auth()->id()]); $manager_conflict = false; $users = User::whereIn('id', $user_raw_array)->where('id', '!=', auth()->id())->get(); @@ -166,7 +166,7 @@ class BulkUsersController extends Controller } // Save the updated info User::whereIn('id', $user_raw_array) - ->where('id', '!=', Auth::id())->update($this->update_array); + ->where('id', '!=', auth()->id())->update($this->update_array); if (array_key_exists('location_id', $this->update_array)){ Asset::where('assigned_type', User::class) @@ -228,7 +228,7 @@ class BulkUsersController extends Controller $user_raw_array = request('ids'); - if (($key = array_search(Auth::id(), $user_raw_array)) !== false) { + if (($key = array_search(auth()->id(), $user_raw_array)) !== false) { unset($user_raw_array[$key]); } diff --git a/app/Http/Controllers/Users/UserFilesController.php b/app/Http/Controllers/Users/UserFilesController.php index 77467a951d..e431182414 100644 --- a/app/Http/Controllers/Users/UserFilesController.php +++ b/app/Http/Controllers/Users/UserFilesController.php @@ -46,7 +46,7 @@ class UserFilesController extends Controller $logAction = new Actionlog(); $logAction->item_id = $user->id; $logAction->item_type = User::class; - $logaction->created_by = Auth::id(); + $logaction->created_by = auth()->id(); $logAction->note = $request->input('notes'); $logAction->target_id = null; $logAction->created_at = date("Y-m-d H:i:s"); diff --git a/app/Http/Requests/ItemImportRequest.php b/app/Http/Requests/ItemImportRequest.php index 2ea0839c93..a6dc0ad7e5 100644 --- a/app/Http/Requests/ItemImportRequest.php +++ b/app/Http/Requests/ItemImportRequest.php @@ -60,7 +60,7 @@ class ItemImportRequest extends FormRequest $fieldMappings = array_change_key_case(array_flip($import->field_map), CASE_LOWER); } $importer->setCallbacks([$this, 'log'], [$this, 'progress'], [$this, 'errorCallback']) - ->setUserId(Auth::id()) + ->setUserId(auth()->id()) ->setUpdating($this->get('import-update')) ->setShouldNotify($this->get('send-welcome')) ->setUsernameFormat('firstname.lastname') diff --git a/app/Http/Transformers/AssetMaintenancesTransformer.php b/app/Http/Transformers/AssetMaintenancesTransformer.php index b186558df6..c5f0abbaab 100644 --- a/app/Http/Transformers/AssetMaintenancesTransformer.php +++ b/app/Http/Transformers/AssetMaintenancesTransformer.php @@ -64,7 +64,10 @@ class AssetMaintenancesTransformer 'start_date' => Helper::getFormattedDateObject($assetmaintenance->start_date, 'date'), 'asset_maintenance_time' => $assetmaintenance->asset_maintenance_time, 'completion_date' => Helper::getFormattedDateObject($assetmaintenance->completion_date, 'date'), - 'user_id' => ($assetmaintenance->admin) ? ['id' => $assetmaintenance->admin->id, 'name'=> e($assetmaintenance->admin->getFullNameAttribute())] : null, + 'user_id' => ($assetmaintenance->adminuser) ? [ + 'id' => $assetmaintenance->adminuser->id, + 'name'=> e($assetmaintenance->admin->getFullNameAttribute()) + ] : null, // legacy to not change the shape of the API 'created_by' => ($assetmaintenance->adminuser) ? [ 'id' => (int) $assetmaintenance->adminuser->id, 'name'=> e($assetmaintenance->adminuser->present()->fullName()), diff --git a/app/Models/License.php b/app/Models/License.php index ea71e139ac..4923072f07 100755 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -183,7 +183,7 @@ class License extends Depreciable $logAction = new Actionlog; $logAction->item_type = self::class; $logAction->item_id = $license->id; - $logAction->created_by = Auth::id() ?: 1; // We don't have an id while running the importer from CLI. + $logAction->created_by = auth()->id() ?: 1; // We don't have an id while running the importer from CLI. $logAction->note = "deleted ${change} seats"; $logAction->target_id = null; $logAction->logaction('delete seats'); @@ -215,7 +215,7 @@ class License extends Depreciable $logAction = new Actionlog(); $logAction->item_type = self::class; $logAction->item_id = $license->id; - $logAction->created_by = Auth::id() ?: 1; // Importer. + $logAction->created_by = auth()->id() ?: 1; // Importer. $logAction->note = "added ${change} seats"; $logAction->target_id = null; $logAction->logaction('add seats'); diff --git a/app/Models/Requestable.php b/app/Models/Requestable.php index bf5c9c427b..4dead82bb3 100644 --- a/app/Models/Requestable.php +++ b/app/Models/Requestable.php @@ -29,19 +29,19 @@ trait Requestable public function request($qty = 1) { $this->requests()->save( - new CheckoutRequest(['user_id' => Auth::id(), 'qty' => $qty]) + new CheckoutRequest(['user_id' => auth()->id(), 'qty' => $qty]) ); } public function deleteRequest() { - $this->requests()->where('user_id', Auth::id())->delete(); + $this->requests()->where('user_id', auth()->id())->delete(); } public function cancelRequest($user_id = null) { if (!$user_id){ - $user_id = Auth::id(); + $user_id = auth()->id(); } $this->requests()->where('user_id', $user_id)->update(['canceled_at' => \Carbon\Carbon::now()]);