diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index e7f2e4f7f7..0a7f2dcbcf 100644 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -70,11 +70,11 @@ class LdapSync extends Command $results = Ldap::findLdapUsers(); if ($this->option('location')!='') { - $location = Location::where('name','=',$this->option('location'))->first(); + $location = Location::where('name', '=', $this->option('location'))->first(); LOG::debug('Location name '.$this->option('location').' passed'); LOG::debug('Importing to '.$location->name.' ('.$location->id.')'); } elseif ($this->option('location_id')!='') { - $location = Location::where('id','=',$this->option('location_id'))->first(); + $location = Location::where('id', '=', $this->option('location_id'))->first(); LOG::debug('Location ID '.$this->option('location_id').' passed'); LOG::debug('Importing to '.$location->name.' ('.$location->id.')'); } else { @@ -146,7 +146,7 @@ class LdapSync extends Command if ($this->option('summary')) { for ($x = 0; $x < count($summary); $x++) { if ($summary[$x]['status']=='error') { - $this->error('ERROR: '.$summary[$x]['firstname'].' '.$summary[$x]['lastname'].' (username: '.$summary[$x]['username'].' was not imported: '.$summary[$x]['note'] ); + $this->error('ERROR: '.$summary[$x]['firstname'].' '.$summary[$x]['lastname'].' (username: '.$summary[$x]['username'].' was not imported: '.$summary[$x]['note']); } else { $this->info('User '.$summary[$x]['firstname'].' '.$summary[$x]['lastname'].' (username: '.$summary[$x]['username'].' was '.strtoupper($summary[$x]['createorupdate']).'.'); } @@ -159,6 +159,4 @@ class LdapSync extends Command } - - } diff --git a/app/Console/Commands/ObjectImportCommand.php b/app/Console/Commands/ObjectImportCommand.php index 3ad3dc6856..7d31620542 100644 --- a/app/Console/Commands/ObjectImportCommand.php +++ b/app/Console/Commands/ObjectImportCommand.php @@ -125,12 +125,12 @@ class ObjectImportCommand extends Command } public function progress($count) { - if(!$this->bar) { + if (!$this->bar) { $this->bar = $this->output->createProgressBar($count); } static $index =0; $index++; - if($index < $count) { + if ($index < $count) { $this->bar->advance(); } else { $this->bar->finish(); diff --git a/app/Console/Commands/Versioning.php b/app/Console/Commands/Versioning.php index 91f1d93d3e..c540ff0a24 100644 --- a/app/Console/Commands/Versioning.php +++ b/app/Console/Commands/Versioning.php @@ -42,7 +42,7 @@ class Versioning extends Command { $versionFile = 'config/version.php'; - $hash_version = str_replace("\n",'',shell_exec('git describe --tags')); + $hash_version = str_replace("\n", '', shell_exec('git describe --tags')); $version = explode('-', $hash_version); @@ -52,18 +52,19 @@ class Versioning extends Command 'build_version' => $version[1], 'hash_version' => $version[2], 'full_hash' => $hash_version), - true); + true + ); // Construct our file content - $content = <<line('Setting version: '. config('version.app_version').' build '.config('version.build_version').' ('.config('version.hash_version').')'); + \File::put($versionFile, $content); + $this->line('Setting version: '. config('version.app_version').' build '.config('version.build_version').' ('.config('version.hash_version').')'); } /** diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 75714a1a9a..c35b82a436 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -46,20 +46,20 @@ class Handler extends ExceptionHandler public function render($request, Exception $e) { if ($e instanceof \Illuminate\Session\TokenMismatchException) { - return redirect()->back()->with('error', trans('general.token_expired')); + return redirect()->back()->with('error', trans('general.token_expired')); } if ($this->isHttpException($e)) { - $statusCode = $e->getStatusCode(); + $statusCode = $e->getStatusCode(); - switch ($statusCode) { + switch ($statusCode) { - case '404': - return response()->view('layouts/basic', [ + case '404': + return response()->view('layouts/basic', [ 'content' => view('errors/404') - ]); - } + ]); + } } return parent::render($request, $e); diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 833278efae..4d9269315c 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -31,7 +31,8 @@ class Helper * @since [v2.0] * @return String */ - public static function parseEscapedMarkedown($str) { + public static function parseEscapedMarkedown($str) + { $Parsedown = new \Parsedown(); if ($str) { @@ -173,8 +174,9 @@ class Helper $categories = Category::orderBy('name', 'asc') ->whereNull('deleted_at') ->orderBy('name', 'asc'); - if(!empty($category_type)) + if (!empty($category_type)) { $categories = $categories->where('category_type', '=', $category_type); + } $category_list = array('' => trans('general.select_category')) + $categories->pluck('name', 'id')->toArray(); return $category_list; } @@ -309,7 +311,7 @@ class Helper { $users_list = array( '' => trans('general.select_user')) + Company::scopeCompanyables(User::where('deleted_at', '=', null)) - ->where('show_in_list','=',1) + ->where('show_in_list', '=', 1) ->orderBy('last_name', 'asc') ->orderBy('first_name', 'asc')->get() ->pluck('complete_name', 'id')->toArray(); @@ -554,7 +556,7 @@ class Helper if ($permission[$x]['display'] === true) { if ($selected_arr) { - if (array_key_exists($permission_name,$selected_arr)) { + if (array_key_exists($permission_name, $selected_arr)) { $permissions_arr[$permission_name] = $selected_arr[$permission_name]; } else { $permissions_arr[$permission_name] = '0'; @@ -585,7 +587,8 @@ class Helper * @since [v3.0] * @return boolean */ - public static function checkIfRequired($class, $field) { + public static function checkIfRequired($class, $field) + { $rules = $class::rules(); foreach ($rules as $rule_name => $rule) { if ($rule_name == $field) { @@ -612,7 +615,7 @@ class Helper */ public static function array_smart_fetch(array $array, $key, $default = '') { - array_change_key_case($array, CASE_LOWER); + array_change_key_case($array, CASE_LOWER); return array_key_exists(strtolower($key), array_change_key_case($array)) ? e(trim($array[ $key ])) : $default; } @@ -647,7 +650,8 @@ class Helper * @param String $string * @return string */ - public static function gracefulDecrypt(CustomField $field, $string) { + public static function gracefulDecrypt(CustomField $field, $string) + { if ($field->isFieldDecryptable($string)) { @@ -675,7 +679,8 @@ class Helper * @param $array array * @return Array */ - public static function stripTagsFromJSON(Array $array) { + public static function stripTagsFromJSON(array $array) + { foreach ($array as $key => $value) { $clean_value = strip_tags($value); @@ -699,7 +704,7 @@ class Helper public static function generateDatatableButton($type, $route, $enabled = true, $message = null, $itemName = null) { $disabledString = $enabled ? '' : 'disabled'; - switch($type) { + switch ($type) { case 'checkout': return '' . trans('general.checkout') . ''; case 'checkin': @@ -714,5 +719,4 @@ class Helper return ''; } } - } diff --git a/app/Http/Controllers/AssetMaintenancesController.php b/app/Http/Controllers/AssetMaintenancesController.php index 6d4f3fafe0..0e3cb3431c 100644 --- a/app/Http/Controllers/AssetMaintenancesController.php +++ b/app/Http/Controllers/AssetMaintenancesController.php @@ -74,7 +74,7 @@ class AssetMaintenancesController extends Controller */ public function getDatatable(Request $request) { - $maintenances = AssetMaintenance::with('asset', 'supplier', 'asset.company','admin'); + $maintenances = AssetMaintenance::with('asset', 'supplier', 'asset.company', 'admin'); if (Input::has('search')) { $maintenances = $maintenances->TextSearch(e($request->input('search'))); @@ -107,12 +107,12 @@ class AssetMaintenancesController extends Controller if (Gate::allows('update', Asset::class)) { $actions .= Helper::generateDatatableButton('edit', route('maintenances.edit', $maintenance->id)); $actions .= Helper::generateDatatableButton( - 'delete', - route('maintenances.destroy', $maintenance->id), - $enabled = true, - trans('admin/asset_maintenances/message.delete.confirm'), - $maintenance->title - ); + 'delete', + route('maintenances.destroy', $maintenance->id), + $enabled = true, + trans('admin/asset_maintenances/message.delete.confirm'), + $maintenance->title + ); } if (($maintenance->cost) && (isset($maintenance->asset)) && ($maintenance->asset->assetloc) && ($maintenance->asset->assetloc->currency!='')) { diff --git a/app/Http/Controllers/AssetModelsController.php b/app/Http/Controllers/AssetModelsController.php index 687742341d..8b2edf54a3 100755 --- a/app/Http/Controllers/AssetModelsController.php +++ b/app/Http/Controllers/AssetModelsController.php @@ -418,7 +418,7 @@ class AssetModelsController extends Controller if (Input::has('search')) { $assets = $assets->TextSearch(e($request->input('search'))); } - $offset = request('offset',0); + $offset = request('offset', 0); $limit = request('limit', 50); diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php index a64de53d18..cff0750d7a 100755 --- a/app/Http/Controllers/AssetsController.php +++ b/app/Http/Controllers/AssetsController.php @@ -156,7 +156,7 @@ class AssetsController extends Controller $asset->archived = '0'; $asset->physical = '1'; $asset->depreciate = '0'; - $asset->status_id = request('status_id',0); + $asset->status_id = request('status_id', 0); $asset->warranty_months = request('warranty_months', null); $asset->purchase_cost = Helper::ParseFloat(Input::get('purchase_cost')); $asset->purchase_date = request('purchase_date', null); @@ -784,7 +784,7 @@ class AssetsController extends Controller // We use hardware instead of asset in the url $redirectTo = "hardware"; - switch(request('import-type')) { + switch (request('import-type')) { case "asset": $redirectTo = "hardware.index"; break; @@ -819,7 +819,7 @@ class AssetsController extends Controller return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist')); } - $this->authorize('create',$asset_to_clone); + $this->authorize('create', $asset_to_clone); $asset = clone $asset_to_clone; $asset->id = null; @@ -882,7 +882,7 @@ class AssetsController extends Controller $status['success'] = array(); - foreach($results as $row) { + foreach ($results as $row) { if (is_array($row)) { @@ -899,37 +899,37 @@ class AssetsController extends Controller $item[$asset_tag][$batch_counter]['name'] = Helper::array_smart_fetch($row, "name"); $item[$asset_tag][$batch_counter]['email'] = Helper::array_smart_fetch($row, "email"); - if ($asset = Asset::where('asset_tag','=',$asset_tag)->first()) { + if ($asset = Asset::where('asset_tag', '=', $asset_tag)->first()) { $item[$asset_tag][$batch_counter]['asset_id'] = $asset->id; - $base_username = User::generateFormattedNameFromFullName(Setting::getSettings()->username_format,$item[$asset_tag][$batch_counter]['name']); - $user = User::where('username','=',$base_username['username']); + $base_username = User::generateFormattedNameFromFullName(Setting::getSettings()->username_format, $item[$asset_tag][$batch_counter]['name']); + $user = User::where('username', '=', $base_username['username']); $user_query = ' on username '.$base_username['username']; if ($request->input('match_firstnamelastname')=='1') { - $firstnamedotlastname = User::generateFormattedNameFromFullName('firstname.lastname',$item[$asset_tag][$batch_counter]['name']); + $firstnamedotlastname = User::generateFormattedNameFromFullName('firstname.lastname', $item[$asset_tag][$batch_counter]['name']); $item[$asset_tag][$batch_counter]['username'][] = $firstnamedotlastname['username']; - $user->orWhere('username','=',$firstnamedotlastname['username']); + $user->orWhere('username', '=', $firstnamedotlastname['username']); $user_query .= ', or on username '.$firstnamedotlastname['username']; } if ($request->input('match_flastname')=='1') { - $flastname = User::generateFormattedNameFromFullName('filastname',$item[$asset_tag][$batch_counter]['name']); + $flastname = User::generateFormattedNameFromFullName('filastname', $item[$asset_tag][$batch_counter]['name']); $item[$asset_tag][$batch_counter]['username'][] = $flastname['username']; - $user->orWhere('username','=',$flastname['username']); + $user->orWhere('username', '=', $flastname['username']); $user_query .= ', or on username '.$flastname['username']; } if ($request->input('match_firstname')=='1') { - $firstname = User::generateFormattedNameFromFullName('firstname',$item[$asset_tag][$batch_counter]['name']); + $firstname = User::generateFormattedNameFromFullName('firstname', $item[$asset_tag][$batch_counter]['name']); $item[$asset_tag][$batch_counter]['username'][] = $firstname['username']; - $user->orWhere('username','=',$firstname['username']); + $user->orWhere('username', '=', $firstname['username']); $user_query .= ', or on username '.$firstname['username']; } if ($request->input('match_email')=='1') { if ($item[$asset_tag][$batch_counter]['email']=='') { $item[$asset_tag][$batch_counter]['username'][] = $user_email = User::generateEmailFromFullName($item[$asset_tag][$batch_counter]['name']); - $user->orWhere('username','=',$user_email); + $user->orWhere('username', '=', $user_email); $user_query .= ', or on username '.$user_email; } } @@ -948,8 +948,7 @@ class AssetsController extends Controller 'target_type' => User::class, 'created_at' => $item[$asset_tag][$batch_counter]['checkout_date'], 'action_type' => 'checkout', - ) - ); + )); $asset->assigned_to = $user->id; @@ -974,13 +973,13 @@ class AssetsController extends Controller // Loop through and backfill the checkins foreach ($item as $key => $asset_batch) { $total_in_batch = count($asset_batch); - for($x = 0; $x < $total_in_batch; $x++) { + for ($x = 0; $x < $total_in_batch; $x++) { $next = $x + 1; // Only do this if a matching user was found - if ((array_key_exists('checkedout_to',$asset_batch[$x])) && ($asset_batch[$x]['checkedout_to']!='')) { + if ((array_key_exists('checkedout_to', $asset_batch[$x])) && ($asset_batch[$x]['checkedout_to']!='')) { - if (($total_in_batch > 1) && ($x < $total_in_batch) && (array_key_exists($next,$asset_batch))) { + if (($total_in_batch > 1) && ($x < $total_in_batch) && (array_key_exists($next, $asset_batch))) { $checkin_date = Carbon::parse($asset_batch[$next]['checkout_date'])->subDay(1)->format('Y-m-d H:i:s'); $asset_batch[$x]['real_checkin'] = $checkin_date; @@ -992,13 +991,12 @@ class AssetsController extends Controller 'target_id' => null, 'created_at' => $checkin_date, 'action_type' => 'checkin' - ) - ); + )); } } } } - return View::make('hardware/history')->with('status',$status); + return View::make('hardware/history')->with('status', $status); } /** @@ -1152,12 +1150,14 @@ class AssetsController extends Controller // Create labels if (Input::get('bulk_actions')=='labels') { $count = 0; - return View::make('hardware/labels')->with('assets', Asset::find($asset_ids))->with('settings', Setting::getSettings())->with('count', $count)->with('settings', - Setting::getSettings()); + return View::make('hardware/labels')->with('assets', Asset::find($asset_ids))->with('settings', Setting::getSettings())->with('count', $count)->with( + 'settings', + Setting::getSettings() + ); } elseif (Input::get('bulk_actions')=='delete') { $assets = Asset::with('assigneduser', 'assetloc')->find($asset_ids); - $assets->each(function($asset) { - $this->authorize('delete',$asset); + $assets->each(function ($asset) { + $this->authorize('delete', $asset); }); return View::make('hardware/bulk-delete')->with('assets', $assets); // Bulk edit @@ -1168,8 +1168,10 @@ class AssetsController extends Controller ->with('statuslabel_list', Helper::statusLabelList()) ->with('location_list', Helper::locationsList()) ->with('models_list', Helper::modelList()) - ->with('companies_list', - array('' => '') + array('clear' => trans('general.remove_company')) + Helper::companyList()); + ->with( + 'companies_list', + array('' => '') + array('clear' => trans('general.remove_company')) + Helper::companyList() + ); } } return redirect()->back()->with('error', 'No action selected'); @@ -1347,7 +1349,7 @@ class AssetsController extends Controller } if ($request->has('status_id')) { - $assets->where('status_id','=', e($request->get('status_id'))); + $assets->where('status_id', '=', e($request->get('status_id'))); } $allowed_columns = [ @@ -1429,60 +1431,58 @@ class AssetsController extends Controller return $data; } - public function getBulkCheckout() - { + public function getBulkCheckout() + { $this->authorize('checkout', Asset::class); - // Filter out assets that are not deployable. - $assets_list = Company::scopeCompanyables(Asset::RTD()->get(), 'assets.company_id')->pluck('detailed_name', 'id')->toArray(); - return View::make('hardware/bulk-checkout') - ->with('users_list', Helper::usersList()) - ->with('assets_list', $assets_list); - } + // Filter out assets that are not deployable. + $assets_list = Company::scopeCompanyables(Asset::RTD()->get(), 'assets.company_id')->pluck('detailed_name', 'id')->toArray(); + return View::make('hardware/bulk-checkout') + ->with('users_list', Helper::usersList()) + ->with('assets_list', $assets_list); + } - public function postBulkCheckout(Request $request) - { - $this->validate($request, [ - "assigned_to" => 'required' - ]); + public function postBulkCheckout(Request $request) + { + $this->validate($request, [ + "assigned_to" => 'required' + ]); - $user = User::find(e(Input::get('assigned_to'))); - $admin = Auth::user(); + $user = User::find(e(Input::get('assigned_to'))); + $admin = Auth::user(); - $asset_ids = array_filter(Input::get('selected_assets')); + $asset_ids = array_filter(Input::get('selected_assets')); - if ((Input::has('checkout_at')) && (Input::get('checkout_at')!= date("Y-m-d"))) { - $checkout_at = e(Input::get('checkout_at')); - } else { - $checkout_at = date("Y-m-d H:i:s"); - } + if ((Input::has('checkout_at')) && (Input::get('checkout_at')!= date("Y-m-d"))) { + $checkout_at = e(Input::get('checkout_at')); + } else { + $checkout_at = date("Y-m-d H:i:s"); + } - if (Input::has('expected_checkin')) { - $expected_checkin = e(Input::get('expected_checkin')); - } else { - $expected_checkin = ''; - } + if (Input::has('expected_checkin')) { + $expected_checkin = e(Input::get('expected_checkin')); + } else { + $expected_checkin = ''; + } - $errors = []; - DB::transaction(function() use ($user, $admin, $checkout_at, $expected_checkin, $errors, $asset_ids) - { - foreach($asset_ids as $asset_id) - { - $asset = Asset::find($asset_id); - $this->authorize('checkout', $asset); - $error = $asset->checkOutToUser($user, $admin, $checkout_at, $expected_checkin, e(Input::get('note')), null); + $errors = []; + DB::transaction(function () use ($user, $admin, $checkout_at, $expected_checkin, $errors, $asset_ids) { + + foreach ($asset_ids as $asset_id) { + $asset = Asset::find($asset_id); + $this->authorize('checkout', $asset); + $error = $asset->checkOutToUser($user, $admin, $checkout_at, $expected_checkin, e(Input::get('note')), null); - if($error) { - array_merge_recursive($errors, $asset->getErrors()->toArray()); - } - } - }); + if ($error) { + array_merge_recursive($errors, $asset->getErrors()->toArray()); + } + } + }); - if (!$errors) { - // Redirect to the new asset page - return redirect()->to("hardware")->with('success', trans('admin/hardware/message.checkout.success')); - } + if (!$errors) { + // Redirect to the new asset page + return redirect()->to("hardware")->with('success', trans('admin/hardware/message.checkout.success')); + } // Redirect to the asset management page with error - return redirect()->to("hardware/bulk-checkout")->with('error', trans('admin/hardware/message.checkout.error'))->withErrors($errors); - } - + return redirect()->to("hardware/bulk-checkout")->with('error', trans('admin/hardware/message.checkout.error'))->withErrors($errors); + } } diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 9cdc7a76f5..0282bbeb5d 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -36,7 +36,8 @@ class ForgotPasswordController extends Controller * Overriding method "getEmailSubject()" from trait "use ResetsPasswords" * @return string */ - public function getEmailSubject(){ + public function getEmailSubject() + { return property_exists($this, 'subject') ? $this->subject : \Lang::get('mail.reset_link'); } diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 846b06d799..b9e21fcba4 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -17,8 +17,6 @@ use Log; use View; use PragmaRX\Google2FA\Google2FA; - - /** * This controller handles authentication for the user, including local * database users and LDAP users. @@ -65,7 +63,7 @@ class LoginController extends Controller { LOG::debug("Binding user to LDAP."); $ldap_user = Ldap::findAndBindUserLdap($request->input('username'), $request->input('password')); - if(!$ldap_user) { + if (!$ldap_user) { LOG::debug("LDAP user ".$request->input('username')." not found in LDAP or could not bind"); throw new \Exception("Could not find user in LDAP directory"); } else { @@ -73,7 +71,7 @@ class LoginController extends Controller } // Check if the user already exists in the database and was imported via LDAP - $user = User::where('username', '=', Input::get('username'))->whereNull('deleted_at')->where('ldap_import','=',1)->first(); + $user = User::where('username', '=', Input::get('username'))->whereNull('deleted_at')->where('ldap_import', '=', 1)->first(); LOG::debug("Local auth lookup complete"); // The user does not exist in the database. Try to get them from LDAP. @@ -135,8 +133,8 @@ class LoginController extends Controller if (Setting::getSettings()->ldap_enabled=='1') { LOG::debug("LDAP is enabled."); try { - $user = $this->login_via_ldap($request); - Auth::login($user, true); + $user = $this->login_via_ldap($request); + Auth::login($user, true); // If the user was unable to login via LDAP, log the error and let them fall through to // local authentication. @@ -146,20 +144,20 @@ class LoginController extends Controller } // If the user wasn't authenticated via LDAP, skip to local auth - if(!$user) { - LOG::debug("Authenticating user against database."); + if (!$user) { + LOG::debug("Authenticating user against database."); // Try to log the user in - if (!Auth::attempt(Input::only('username', 'password'), Input::get('remember-me', 0))) { + if (!Auth::attempt(Input::only('username', 'password'), Input::get('remember-me', 0))) { - if (!$lockedOut) { - $this->incrementLoginAttempts($request); - } + if (!$lockedOut) { + $this->incrementLoginAttempts($request); + } - LOG::debug("Local authentication failed."); - return redirect()->back()->withInput()->with('error', trans('auth/message.account_not_found')); - } else { + LOG::debug("Local authentication failed."); + return redirect()->back()->withInput()->with('error', trans('auth/message.account_not_found')); + } else { $this->clearLoginAttempts($request); - } + } } // Get the page we were before @@ -200,7 +198,7 @@ class LoginController extends Controller $user->two_factor_secret ); - return View::make('auth.two_factor_enroll')->with('google2fa_url',$google2fa_url); + return View::make('auth.two_factor_enroll')->with('google2fa_url', $google2fa_url); } @@ -210,7 +208,8 @@ class LoginController extends Controller * * @return Redirect */ - public function getTwoFactorAuth() { + public function getTwoFactorAuth() + { return View::make('auth.two_factor'); } @@ -219,7 +218,8 @@ class LoginController extends Controller * * @return Redirect */ - public function postTwoFactorAuth(Request $request) { + public function postTwoFactorAuth(Request $request) + { if (!Auth::check()) { return redirect()->route('login')->with('error', 'You must be logged in.'); @@ -290,7 +290,7 @@ class LoginController extends Controller $minutes = round($seconds / 60); - $message = \Lang::get('auth/message.throttle',['minutes' => $minutes]); + $message = \Lang::get('auth/message.throttle', ['minutes' => $minutes]); return redirect()->back() ->withInput($request->only($this->username(), 'remember')) @@ -310,8 +310,9 @@ class LoginController extends Controller $maxLoginAttempts = config('auth.throttle.max_attempts'); return $this->limiter()->tooManyAttempts( - $this->throttleKey($request), $maxLoginAttempts, $lockoutTime + $this->throttleKey($request), + $maxLoginAttempts, + $lockoutTime ); } - } diff --git a/app/Http/Controllers/ComponentsController.php b/app/Http/Controllers/ComponentsController.php index a9553536de..bbb2aee7f0 100644 --- a/app/Http/Controllers/ComponentsController.php +++ b/app/Http/Controllers/ComponentsController.php @@ -264,7 +264,7 @@ class ComponentsController extends Controller $this->authorize('checkout', $component); $max_to_checkout = $component->numRemaining(); - $validator = Validator::make($request->all(),[ + $validator = Validator::make($request->all(), [ "asset_id" => "required", "assigned_qty" => "required|numeric|between:1,$max_to_checkout" ]); diff --git a/app/Http/Controllers/CustomFieldsController.php b/app/Http/Controllers/CustomFieldsController.php index 7aca1739a9..ac696cf469 100644 --- a/app/Http/Controllers/CustomFieldsController.php +++ b/app/Http/Controllers/CustomFieldsController.php @@ -114,7 +114,7 @@ class CustomFieldsController extends Controller $field = CustomField::find($field_id); if ($field->fieldset()->detach($fieldset_id)) { - return redirect()->route('fieldsets.show',['fieldset' => $fieldset_id])->with("success", trans('admin/custom_fields/message.field.delete.success')); + return redirect()->route('fieldsets.show', ['fieldset' => $fieldset_id])->with("success", trans('admin/custom_fields/message.field.delete.success')); } return redirect()->back()->withErrors(['message' => "Field is in-use"]); diff --git a/app/Http/Controllers/CustomFieldsetsController.php b/app/Http/Controllers/CustomFieldsetsController.php index 1026da218c..27bf69e038 100644 --- a/app/Http/Controllers/CustomFieldsetsController.php +++ b/app/Http/Controllers/CustomFieldsetsController.php @@ -34,24 +34,24 @@ class CustomFieldsetsController extends Controller * @since [v1.8] * @return View */ - public function show($id) - { - $cfset = CustomFieldset::with('fields')->where('id','=',$id)->orderBy('id','ASC')->first(); - $custom_fields_list = ["" => "Add New Field to Fieldset"] + CustomField::pluck("name", "id")->toArray(); + public function show($id) + { + $cfset = CustomFieldset::with('fields')->where('id', '=', $id)->orderBy('id', 'ASC')->first(); + $custom_fields_list = ["" => "Add New Field to Fieldset"] + CustomField::pluck("name", "id")->toArray(); - $maxid = 0; - foreach ($cfset->fields() as $field) { - if ($field->pivot->order > $maxid) { - $maxid=$field->pivot->order; - } - if (isset($custom_fields_list[$field->id])) { - unset($custom_fields_list[$field->id]); - } + $maxid = 0; + foreach ($cfset->fields() as $field) { + if ($field->pivot->order > $maxid) { + $maxid=$field->pivot->order; + } + if (isset($custom_fields_list[$field->id])) { + unset($custom_fields_list[$field->id]); } - - return View::make("custom_fields.fieldset")->with("custom_fieldset", $cfset)->with("maxid", $maxid+1)->with("custom_fields_list", $custom_fields_list); } + return View::make("custom_fields.fieldset")->with("custom_fieldset", $cfset)->with("maxid", $maxid+1)->with("custom_fields_list", $custom_fields_list); + } + /** * Returns a view with a form for creating a new custom fieldset. @@ -80,7 +80,7 @@ class CustomFieldsetsController extends Controller [ "name" => e($request->get("name")), "user_id" => Auth::user()->id] - ); + ); $validator = Validator::make(Input::all(), $cfset->rules); if ($validator->passes()) { @@ -169,5 +169,4 @@ class CustomFieldsetsController extends Controller return redirect()->route("fieldsets.show", [$id])->with("success", trans('admin/custom_fields/message.field.create.assoc_success')); } - } diff --git a/app/Http/Controllers/LicensesController.php b/app/Http/Controllers/LicensesController.php index d63145fdec..983c7059d3 100755 --- a/app/Http/Controllers/LicensesController.php +++ b/app/Http/Controllers/LicensesController.php @@ -587,7 +587,7 @@ class LicensesController extends Controller $upload_success = $file->move($destinationPath, $filename); //Log the upload to the log - $license->logUpload($filename, e($request->input('notes'))); + $license->logUpload($filename, e($request->input('notes'))); } if ($upload_success) { diff --git a/app/Http/Controllers/ManufacturersController.php b/app/Http/Controllers/ManufacturersController.php index f2afea9b19..c346818c76 100755 --- a/app/Http/Controllers/ManufacturersController.php +++ b/app/Http/Controllers/ManufacturersController.php @@ -302,7 +302,7 @@ class ManufacturersController extends Controller 'accessories.category', 'accessories.manufacturer', 'accessories.users' - ); + ); $accessories = $manufacturer->accessories(); if ($request->has('search')) { diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 55d1a77021..9af67f3e1b 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -117,11 +117,11 @@ class ReportsController extends Controller $customfields = CustomField::get(); - $response = new StreamedResponse(function() use ($customfields) { + $response = new StreamedResponse(function () use ($customfields) { // Open output stream $handle = fopen('php://output', 'w'); - Asset::with('assigneduser', 'assetloc','defaultLoc','assigneduser.userloc','model','supplier','assetstatus','model.manufacturer')->orderBy('created_at', 'DESC')->chunk(500, function($assets) use($handle, $customfields) { + Asset::with('assigneduser', 'assetloc', 'defaultLoc', 'assigneduser.userloc', 'model', 'supplier', 'assetstatus', 'model.manufacturer')->orderBy('created_at', 'DESC')->chunk(500, function ($assets) use ($handle, $customfields) { $headers=[ trans('general.company'), trans('admin/hardware/table.asset_tag'), @@ -140,7 +140,7 @@ class ReportsController extends Controller trans('admin/hardware/table.location'), trans('general.notes'), ]; - foreach($customfields as $field) { + foreach ($customfields as $field) { $headers[]=$field->name; } fputcsv($handle, $headers); @@ -166,7 +166,7 @@ class ReportsController extends Controller e($asset->assigneduser->userloc->name) : ( ($asset->defaultLoc!='') ? e($asset->defaultLoc->name) : ''), ($asset->notes) ? e($asset->notes) : '', ]; - foreach($customfields as $field) { + foreach ($customfields as $field) { $values[]=$asset->{$field->db_column_name()}; } fputcsv($handle, $values); @@ -339,7 +339,7 @@ class ReportsController extends Controller foreach ($activitylogs as $activity) { if (($activity->item) && ($activity->itemType()=="asset")) { - $activity_item = ''.e($activity->item->asset_tag).' - '. e($activity->item->present()->name()).''; + $activity_item = ''.e($activity->item->asset_tag).' - '. e($activity->item->present()->name()).''; $item_type = 'asset'; } elseif ($activity->item) { $activity_item = '' . e($activity->item->name) . ''; @@ -353,14 +353,14 @@ class ReportsController extends Controller if (($activity->user) && ($activity->action_type=="uploaded") && ($activity->itemType()=="user")) { $activity_target = ''.$activity->user->present()->fullName().''; } elseif ($activity->target_type === "App\Models\Asset") { - if($activity->target) { + if ($activity->target) { $activity_target = ''.$activity->target->present()->name().''; } else { $activity_target = ""; } - } elseif ( $activity->target_type === "App\Models\User") { - if($activity->target) { - $activity_target = ''.$activity->target->present()->fullName().''; + } elseif ($activity->target_type === "App\Models\User") { + if ($activity->target) { + $activity_target = ''.$activity->target->present()->fullName().''; } else { $activity_target = ''; } @@ -374,7 +374,7 @@ class ReportsController extends Controller $activity_target = ''; } } else { - if($activity->target) { + if ($activity->target) { $activity_target = $activity->target->id; } else { $activity_target = ""; @@ -385,7 +385,7 @@ class ReportsController extends Controller $rows[] = array( 'icon' => '', 'created_at' => date("M d, Y g:iA", strtotime($activity->created_at)), - 'action_type' => strtolower(trans('general.'.str_replace(' ','_',$activity->action_type))), + 'action_type' => strtolower(trans('general.'.str_replace(' ', '_', $activity->action_type))), 'admin' => $activity->user ? (string) link_to_route('users.show', $activity->user->present()->fullName(), [$activity->user_id]) : '', 'target' => $activity_target, 'item' => $activity_item, @@ -492,7 +492,7 @@ class ReportsController extends Controller */ public function postCustom() { - $assets = Asset::orderBy('created_at', 'DESC')->with('company','assigneduser', 'assetloc','defaultLoc','assigneduser.userloc','model','supplier','assetstatus','model.manufacturer')->get(); + $assets = Asset::orderBy('created_at', 'DESC')->with('company', 'assigneduser', 'assetloc', 'defaultLoc', 'assigneduser.userloc', 'model', 'supplier', 'assetstatus', 'model.manufacturer')->get(); $customfields = CustomField::get(); $rows = [ ]; diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index ce152316ac..d8344d5e6c 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -21,7 +21,6 @@ use App\Models\User; use App\Http\Requests\SetupUserRequest; use App\Http\Requests\ImageUploadRequest; - /** * This controller handles all actions related to Settings for * the Snipe-IT Asset Management application. @@ -58,7 +57,7 @@ class SettingsController extends Controller $host = $_SERVER['SERVER_NAME']; if (($protocol === 'http://' && $_SERVER['SERVER_PORT'] != '80') || ($protocol === 'https://' && $_SERVER['SERVER_PORT'] != '443')) { - $host .= ':' . $_SERVER['SERVER_PORT']; + $host .= ':' . $_SERVER['SERVER_PORT']; } $pageURL = $protocol . $host . $_SERVER['REQUEST_URI']; @@ -443,7 +442,8 @@ class SettingsController extends Controller } - public function getLdapTest() { + public function getLdapTest() + { try { $connection = Ldap::connectToLdap(); diff --git a/app/Http/Controllers/StatuslabelsController.php b/app/Http/Controllers/StatuslabelsController.php index e7939b95ae..c57caa67f8 100755 --- a/app/Http/Controllers/StatuslabelsController.php +++ b/app/Http/Controllers/StatuslabelsController.php @@ -207,7 +207,7 @@ class StatuslabelsController extends Controller $statuslabel->pending = $statustype['pending']; $statuslabel->archived = $statustype['archived']; $statuslabel->color = Input::get('color'); - $statuslabel->show_in_nav = Input::get('show_in_nav',0); + $statuslabel->show_in_nav = Input::get('show_in_nav', 0); // Was the asset created? diff --git a/app/Http/Controllers/SuppliersController.php b/app/Http/Controllers/SuppliersController.php index 51bc9bcb4f..585e91d94f 100755 --- a/app/Http/Controllers/SuppliersController.php +++ b/app/Http/Controllers/SuppliersController.php @@ -200,8 +200,10 @@ class SuppliersController extends Controller // Delete the supplier $supplier->delete(); // Redirect to the suppliers management page - return redirect()->route('suppliers.index')->with('success', - trans('admin/suppliers/message.delete.success')); + return redirect()->route('suppliers.index')->with( + 'success', + trans('admin/suppliers/message.delete.success') + ); } // Redirect to the asset management page return redirect()->route('suppliers.index')->with('error', trans('admin/suppliers/message.assoc_users')); diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index 3d0a4c27c7..e1f77d9dff 100755 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -217,13 +217,14 @@ class UsersController extends Controller * @internal param int $id */ - private function filterDisplayable($permissions) { + private function filterDisplayable($permissions) + { $output = null; - foreach($permissions as $key=>$permission) { - $output[$key] = array_filter($permission, function($p) { + foreach ($permissions as $key => $permission) { + $output[$key] = array_filter($permission, function ($p) { return $p['display'] === true; }); - } + } return $output; } @@ -308,7 +309,7 @@ class UsersController extends Controller if ($request->has('password')) { $user->password = bcrypt($request->input('password')); } - if ( $request->has('username')) { + if ($request->has('username')) { $user->username = e($request->input('username')); } $user->email = e($request->input('email')); @@ -334,7 +335,7 @@ class UsersController extends Controller if (!Auth::user()->isSuperUser()) { unset($permissions_array['superuser']); $permissions_array['superuser'] = $orig_superuser; - } + } $user->permissions = json_encode($permissions_array); @@ -550,7 +551,7 @@ class UsersController extends Controller */ public function show($userId = null) { - if(!$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find($userId)) { + if (!$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find($userId)) { $error = trans('admin/users/message.user_not_found', compact('id')); // Redirect to the user management page return redirect()->route('users.index')->with('error', $error); @@ -815,7 +816,7 @@ class UsersController extends Controller 'users.company_id', 'users.deleted_at', 'users.activated' - ])->with('manager', 'groups', 'userloc', 'company','throttle'); + ])->with('manager', 'groups', 'userloc', 'company', 'throttle'); $users = Company::scopeCompanyables($users); switch ($status) { @@ -1036,13 +1037,13 @@ class UsersController extends Controller try { $ldapconn = Ldap::connectToLdap(); } catch (\Exception $e) { - return redirect()->back()->withInput()->with('error',$e->getMessage()); + return redirect()->back()->withInput()->with('error', $e->getMessage()); } try { Ldap::bindAdminToLdap($ldapconn); } catch (\Exception $e) { - return redirect()->back()->withInput()->with('error',$e->getMessage()); + return redirect()->back()->withInput()->with('error', $e->getMessage()); } $summary = array(); @@ -1128,11 +1129,11 @@ class UsersController extends Controller $this->authorize('view', User::class); \Debugbar::disable(); - $response = new StreamedResponse(function() { + $response = new StreamedResponse(function () { // Open output stream $handle = fopen('php://output', 'w'); - User::with('assets', 'accessories', 'consumables', 'licenses', 'manager', 'groups', 'userloc', 'company','throttle')->orderBy('created_at', 'DESC')->chunk(500, function($users) use($handle) { + User::with('assets', 'accessories', 'consumables', 'licenses', 'manager', 'groups', 'userloc', 'company', 'throttle')->orderBy('created_at', 'DESC')->chunk(500, function ($users) use ($handle) { $headers=[ // strtolower to prevent Excel from trying to open it as a SYLK file strtolower(trans('general.id')), diff --git a/app/Http/Controllers/ViewAssetsController.php b/app/Http/Controllers/ViewAssetsController.php index 76e13ce632..553b5c5c50 100755 --- a/app/Http/Controllers/ViewAssetsController.php +++ b/app/Http/Controllers/ViewAssetsController.php @@ -315,7 +315,7 @@ class ViewAssetsController extends Controller } elseif (!Company::isCurrentUserHasAccess($item)) { return redirect()->route('requestable-assets')->with('error', trans('general.insufficient_permissions')); } else { - return View::make('account/accept-asset', compact('item'))->with('findlog', $findlog)->with('item',$item); + return View::make('account/accept-asset', compact('item'))->with('findlog', $findlog)->with('item', $item); } } diff --git a/app/Http/Middleware/CheckForDebug.php b/app/Http/Middleware/CheckForDebug.php index 2486f20120..ff78fd31ba 100644 --- a/app/Http/Middleware/CheckForDebug.php +++ b/app/Http/Middleware/CheckForDebug.php @@ -19,7 +19,7 @@ class CheckForDebug view()->share('debug_in_production', false); if (((Auth::check() && (Auth::user()->isSuperUser()))) && (app()->environment()=='production') && (config('app.warn_debug')===true) && (config('app.debug')===true)) { - view()->share('debug_in_production', true); + view()->share('debug_in_production', true); } return $next($request); diff --git a/app/Importer/AccessoryImporter.php b/app/Importer/AccessoryImporter.php index 4da6e13d63..14f2dc194b 100644 --- a/app/Importer/AccessoryImporter.php +++ b/app/Importer/AccessoryImporter.php @@ -8,7 +8,6 @@ namespace App\Importer; - use App\Helpers\Helper; use App\Models\Accessory; @@ -41,7 +40,7 @@ class AccessoryImporter extends ItemImporter $accessory = $this->accessories->search(function ($key) { return strcasecmp($key->name, $this->item['item_name']) == 0; }); - if($accessory) { + if ($accessory) { $editingAccessory = true; if (!$this->updating) { $this->log('A matching Accessory ' . $this->item["item_name"] . ' already exists. '); @@ -101,10 +100,10 @@ class AccessoryImporter extends ItemImporter // $this->comment('Accessory ' . $this->item["item_name"] . ' was created'); } else { - $this->jsonError($accessory,'Accessory', $accessory->getErrors()) ; + $this->jsonError($accessory, 'Accessory', $accessory->getErrors()) ; } } else { $this->log('TEST RUN - Accessory ' . $this->item["item_name"] . ' not created'); } } -} \ No newline at end of file +} diff --git a/app/Importer/AssetImporter.php b/app/Importer/AssetImporter.php index 9cddd49f0c..f70cf4c95d 100644 --- a/app/Importer/AssetImporter.php +++ b/app/Importer/AssetImporter.php @@ -8,7 +8,6 @@ namespace App\Importer; - use App\Helpers\Helper; use App\Models\Asset; use App\Models\Category; @@ -52,7 +51,7 @@ class AssetImporter extends ItemImporter $asset = $this->assets->search(function ($key) { return strcasecmp($key->asset_tag, $this->item['asset_tag']) == 0; }); - if($asset) { + if ($asset) { $editingAsset = true; if (!$this->updating) { $this->log('A matching Asset ' . $this->item['asset_tag'] . ' already exists'); @@ -91,7 +90,7 @@ class AssetImporter extends ItemImporter if (isset($this->item["status_label"])) { $status_id = $this->item["status_label"]->id; - } else if (!$editingAsset) { + } elseif (!$editingAsset) { // Assume if we are editing, we already have a status and can ignore. $this->log("No status field found, defaulting to first status."); $status_id = $this->status_labels->first()->id; @@ -173,4 +172,4 @@ class AssetImporter extends ItemImporter } } } -} \ No newline at end of file +} diff --git a/app/Importer/ConsumableImporter.php b/app/Importer/ConsumableImporter.php index fbcfa16f0e..f374eb7b76 100644 --- a/app/Importer/ConsumableImporter.php +++ b/app/Importer/ConsumableImporter.php @@ -8,7 +8,6 @@ namespace App\Importer; - use App\Helpers\Helper; use App\Models\Consumable; @@ -41,7 +40,7 @@ class ConsumableImporter extends ItemImporter $consumable = $this->consumables->search(function ($key) { return strcasecmp($key->name, $this->item['item_name']) == 0; }); - if($consumable) { + if ($consumable) { $editingConsumable = true; if (!$this->updating) { $this->log('A matching Consumable ' . $this->item["item_name"] . ' already exists. '); @@ -102,4 +101,4 @@ class ConsumableImporter extends ItemImporter $this->log('TEST RUN - Consumable ' . $this->item['item_name'] . ' not created'); } } -} \ No newline at end of file +} diff --git a/app/Importer/Importer.php b/app/Importer/Importer.php index 3617fac555..66c968071a 100644 --- a/app/Importer/Importer.php +++ b/app/Importer/Importer.php @@ -1,7 +1,6 @@ filename = $filename; $this->csv = Reader::createFromPath($filename); $this->csv->setNewLine('\r\n'); @@ -85,7 +86,7 @@ abstract class Importer ini_set("auto_detect_line_endings", '1'); } $this->testRun = $testRun; - if($user_id == -1) { + if ($user_id == -1) { $user_id = Auth::id(); } $this->user_id = $user_id; @@ -193,11 +194,13 @@ abstract class Importer return array_key_exists($index_name, $array) ? e(trim($array[$index_name])) : ''; } - protected function log($string) { + protected function log($string) + { call_user_func($this->logCallback, $string); } - protected function jsonError($item, $field, $errorString) { + protected function jsonError($item, $field, $errorString) + { call_user_func($this->errorCallback, $item, $field, $errorString); } @@ -276,10 +279,10 @@ abstract class Importer if ($user->save()) { $this->log('User '.$first_name.' created'); } else { - $this->jsonError($user,'User "' . $first_name . '"', $user->getErrors()); + $this->jsonError($user, 'User "' . $first_name . '"', $user->getErrors()); } } } return $user; } -} \ No newline at end of file +} diff --git a/app/Importer/ItemImporter.php b/app/Importer/ItemImporter.php index 10d1fbce96..2bd3c957ab 100644 --- a/app/Importer/ItemImporter.php +++ b/app/Importer/ItemImporter.php @@ -2,7 +2,6 @@ namespace App\Importer; - use App\Models\AssetModel; use App\Models\Category; use App\Models\Company; @@ -91,7 +90,7 @@ class ItemImporter extends Importer }); // We need strict compare here because the index returned above can be 0. // This casts to false and causes false positives - if(($asset_model !== false) && !$editingModel) { + if (($asset_model !== false) && !$editingModel) { return $this->asset_models[$asset_model]; } else { $this->log("No Matching Model, Creating a new one"); @@ -116,7 +115,7 @@ class ItemImporter extends Importer $this->log('Asset Model ' . $asset_model_name . ' with model number ' . $asset_modelNumber . ' was created'); return $asset_model; } else { - $this->jsonError($asset_model,'Asset Model "' . $asset_model_name . '"', $asset_model->getErrors()); + $this->jsonError($asset_model, 'Asset Model "' . $asset_model_name . '"', $asset_model->getErrors()); $this->log('Asset Model "' . $asset_model_name . '"' . $asset_model->getErrors()); return $asset_model; } @@ -186,12 +185,12 @@ class ItemImporter extends Importer */ public function createOrFetchCompany($asset_company_name) { - $company = $this->companies->search(function ($key) use($asset_company_name) { + $company = $this->companies->search(function ($key) use ($asset_company_name) { return strcasecmp($key->name, $asset_company_name) == 0; }); // We need strict compare here because the index returned above can be 0. // This casts to false and causes false positives - if($company !== false) { + if ($company !== false) { $this->log('A matching Company ' . $asset_company_name . ' already exists'); return $this->companies[$company]; } @@ -225,7 +224,7 @@ class ItemImporter extends Importer if (empty($asset_statuslabel_name)) { return null; } - $status = $this->status_labels->search(function ($key) use($asset_statuslabel_name) { + $status = $this->status_labels->search(function ($key) use ($asset_statuslabel_name) { return strcasecmp($key->name, $asset_statuslabel_name) == 0; }); // We need strict compare here because the index returned above can be 0. @@ -248,7 +247,7 @@ class ItemImporter extends Importer $this->log('Status ' . $asset_statuslabel_name . ' was created'); return $status; } else { - $this->jsonError($status,'Status "'. $asset_statuslabel_name . '"', $status->getErrors()); + $this->jsonError($status, 'Status "'. $asset_statuslabel_name . '"', $status->getErrors()); return $status; } } else { @@ -272,7 +271,7 @@ class ItemImporter extends Importer if (empty($item_manufacturer)) { $item_manufacturer='Unknown'; } - $manufacturer = $this->manufacturers->search(function ($key) use($item_manufacturer) { + $manufacturer = $this->manufacturers->search(function ($key) use ($item_manufacturer) { return strcasecmp($key->name, $item_manufacturer) == 0; }); // We need strict compare here because the index returned above can be 0. @@ -317,7 +316,7 @@ class ItemImporter extends Importer $this->log('No location given, so none created.'); return null; } - $location = $this->locations->search(function ($key) use($asset_location) { + $location = $this->locations->search(function ($key) use ($asset_location) { return strcasecmp($key->name, $asset_location) == 0; }); // We need strict compare here because the index returned above can be 0. @@ -366,7 +365,7 @@ class ItemImporter extends Importer $item_supplier='Unknown'; } - $supplier = $this->suppliers->search(function ($key) use($item_supplier) { + $supplier = $this->suppliers->search(function ($key) use ($item_supplier) { return strcasecmp($key->name, $item_supplier) == 0; }); // We need strict compare here because the index returned above can be 0. @@ -394,6 +393,4 @@ class ItemImporter extends Importer return $supplier; } } - - -} \ No newline at end of file +} diff --git a/app/Models/Actionlog.php b/app/Models/Actionlog.php index 41a64b8ad4..e83ca9f18c 100755 --- a/app/Models/Actionlog.php +++ b/app/Models/Actionlog.php @@ -26,15 +26,15 @@ class Actionlog extends Model public static function boot() { parent::boot(); - static::creating( function (Actionlog $actionlog) { + static::creating(function (Actionlog $actionlog) { // If the admin is a superadmin, let's see if the target instead has a company. if (Auth::user() && Auth::user()->isSuperUser()) { if ($actionlog->target) { $actionlog->company_id = $actionlog->target->company_id; - } else if ($actionlog->item) { + } elseif ($actionlog->item) { $actionlog->company_id = $actionlog->item->company_id; } - } else if (Auth::user() && Auth::user()->company) { + } elseif (Auth::user() && Auth::user()->company) { $actionlog->company_id = Auth::user()->company_id; } }); @@ -45,27 +45,29 @@ class Actionlog extends Model return $this->morphTo('item')->withTrashed(); } - public function company() { - return $this->hasMany('\App\Models\Company', 'id','company_id'); + public function company() + { + return $this->hasMany('\App\Models\Company', 'id', 'company_id'); } public function itemType() { - if($this->item_type == AssetModel::class) { + if ($this->item_type == AssetModel::class) { return "model"; } return camel_case(class_basename($this->item_type)); } - public function parseItemRoute() { + public function parseItemRoute() + { if ($this->itemType() == "asset") { $itemroute = 'assets'; } elseif ($this->itemType() == "accessory") { $itemroute = 'accessories'; } elseif ($this->itemType()=="consumable") { $itemroute = 'consumables'; - } elseif ($this->itemType()=="license"){ + } elseif ($this->itemType()=="license") { $itemroute = 'licenses'; } elseif ($this->itemType()=="component") { $itemroute = 'components'; @@ -77,14 +79,15 @@ class Actionlog extends Model } - public function parseItemIcon() { + public function parseItemIcon() + { if ($this->itemType() == "asset") { $itemicon = 'fa fa-barcode'; } elseif ($this->itemType() == "accessory") { $itemicon = 'fa fa-keyboard-o'; } elseif ($this->itemType()=="consumable") { $itemicon = 'fa fa-tint'; - } elseif ($this->itemType()=="license"){ + } elseif ($this->itemType()=="license") { $itemicon = 'fa fa-floppy-o'; } elseif ($this->itemType()=="component") { $itemicon = 'fa fa-hdd-o'; diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 995f4085fb..1781a88cf6 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -74,7 +74,7 @@ class Asset extends Depreciable public function availableForCheckout() { - return ( + return ( empty($this->assigned_to) && $this->assetstatus->deployable == 1 && empty($this->deleted_at) @@ -105,7 +105,7 @@ class Asset extends Depreciable $this->assigneduser()->associate($user); - if($name != null) { + if ($name != null) { $this->name = $name; } @@ -359,7 +359,7 @@ class Asset extends Depreciable ->max('id'); if ($settings->zerofill_count > 0) { - return $settings->auto_increment_prefix.Asset::zerofill(($asset_tag + 1),$settings->zerofill_count); + return $settings->auto_increment_prefix.Asset::zerofill(($asset_tag + 1), $settings->zerofill_count); } return $settings->auto_increment_prefix.($asset_tag + 1); } else { @@ -368,7 +368,7 @@ class Asset extends Depreciable } - public static function zerofill ($num, $zerofill = 3) + public static function zerofill($num, $zerofill = 3) { return str_pad($num, $zerofill, '0', STR_PAD_LEFT); } diff --git a/app/Models/AssetMaintenance.php b/app/Models/AssetMaintenance.php index 454320240a..6ef858384d 100644 --- a/app/Models/AssetMaintenance.php +++ b/app/Models/AssetMaintenance.php @@ -58,7 +58,7 @@ class AssetMaintenance extends Model implements ICompanyableChild public function setIsWarrantyAttribute($value) { - if($value == '') { + if ($value == '') { $value = 0; } $this->attributes['is_warranty'] = $value; @@ -70,7 +70,7 @@ class AssetMaintenance extends Model implements ICompanyableChild public function setCostAttribute($value) { $value = Helper::ParseFloat($value); - if($value == '0.0') { + if ($value == '0.0') { $value = null; } $this->attributes['cost'] = $value; @@ -81,7 +81,7 @@ class AssetMaintenance extends Model implements ICompanyableChild */ public function setNotesAttribute($value) { - if($value == '') { + if ($value == '') { $value = null; } $this->attributes['notes'] = $value; @@ -92,7 +92,7 @@ class AssetMaintenance extends Model implements ICompanyableChild */ public function setCompletionDateAttribute($value) { - if($value == '' || $value == "0000-00-00") { + if ($value == '' || $value == "0000-00-00") { $value = null; } $this->attributes['completion_date'] = $value; diff --git a/app/Models/AssetModel.php b/app/Models/AssetModel.php index 6bde3a6b9f..d845600c62 100755 --- a/app/Models/AssetModel.php +++ b/app/Models/AssetModel.php @@ -41,7 +41,8 @@ class AssetModel extends SnipeModel protected $injectUniqueIdentifier = true; use ValidatingTrait; - public function setEolAttribute($value) { + public function setEolAttribute($value) + { if ($value == '') { $value = 0; } diff --git a/app/Models/Company.php b/app/Models/Company.php index 6479d3acac..fe621ff4fe 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -164,26 +164,32 @@ final class Company extends SnipeModel } } - public function users() { + public function users() + { return $this->hasMany(User::class); } - public function assets() { + public function assets() + { return $this->hasMany(Asset::class); } - public function licenses() { + public function licenses() + { return $this->hasMany(License::class); } - public function accessories() { + public function accessories() + { return $this->hasMany(Accessory::class); } - public function consumables() { + public function consumables() + { return $this->hasMany(Consumable::class); } - public function components() { + public function components() + { return $this->hasMany(Component::class); } } diff --git a/app/Models/CustomField.php b/app/Models/CustomField.php index 6fcf74a29b..8f7c7dbfce 100644 --- a/app/Models/CustomField.php +++ b/app/Models/CustomField.php @@ -37,7 +37,7 @@ class CustomField extends Model { self::creating(function ($custom_field) { - if (Schema::hasColumn(CustomField::$table_name,$custom_field->db_column_name())) { + if (Schema::hasColumn(CustomField::$table_name, $custom_field->db_column_name())) { //field already exists when making a new custom field; fail. return false; } @@ -50,20 +50,20 @@ class CustomField extends Model self::updating(function ($custom_field) { if ($custom_field->isDirty("name")) { - if (Schema::hasColumn(CustomField::$table_name,$custom_field->db_column_name())) { + if (Schema::hasColumn(CustomField::$table_name, $custom_field->db_column_name())) { //field already exists when renaming a custom field return false; } return Schema::table(CustomField::$table_name, function ($table) use ($custom_field) { - $table->renameColumn(self::name_to_db_name($custom_field->getOriginal("name")),$custom_field->db_column_name()); + $table->renameColumn(self::name_to_db_name($custom_field->getOriginal("name")), $custom_field->db_column_name()); }); } return true; }); self::deleting(function ($custom_field) { - return Schema::table(CustomField::$table_name,function ($table) use ($custom_field) { - $table->dropColumn(self::name_to_db_name($custom_field->getOriginal("name"))); + return Schema::table(CustomField::$table_name, function ($table) use ($custom_field) { + $table->dropColumn(self::name_to_db_name($custom_field->getOriginal("name"))); }); }); } @@ -122,7 +122,8 @@ class CustomField extends Model * @since [v3.4] * @return Array */ - public function formatFieldValuesAsArray() { + public function formatFieldValuesAsArray() + { $arr = preg_split("/\\r\\n|\\r|\\n/", $this->field_values); $result[''] = 'Select '.strtolower($this->format); @@ -130,7 +131,7 @@ class CustomField extends Model for ($x = 0; $x < count($arr); $x++) { $arr_parts = explode('|', $arr[$x]); if ($arr_parts[0]!='') { - if (key_exists('1',$arr_parts)) { + if (key_exists('1', $arr_parts)) { $result[$arr_parts[0]] = $arr_parts[1]; } else { $result[$arr_parts[0]] = $arr_parts[0]; @@ -143,14 +144,11 @@ class CustomField extends Model return $result; } - public function isFieldDecryptable($string) { + public function isFieldDecryptable($string) + { if (($this->field_encrypted=='1') && ($string!='')) { return true; } return false; } - - - - } diff --git a/app/Models/CustomFieldset.php b/app/Models/CustomFieldset.php index 5b185cadde..62b2f1a2e8 100644 --- a/app/Models/CustomFieldset.php +++ b/app/Models/CustomFieldset.php @@ -34,9 +34,7 @@ class CustomFieldset extends Model $rule = []; if (($field->field_encrypted!='1') || - (($field->field_encrypted =='1') && (Gate::allows('admin')) )) - { - + (($field->field_encrypted =='1') && (Gate::allows('admin')) )) { if ($field->pivot->required) { $rule[]="required"; } @@ -47,5 +45,4 @@ class CustomFieldset extends Model } return $rules; } - } diff --git a/app/Models/Ldap.php b/app/Models/Ldap.php index fe5ee173ed..0373eeedfa 100644 --- a/app/Models/Ldap.php +++ b/app/Models/Ldap.php @@ -8,7 +8,6 @@ use Exception; use Input; use Log; - class Ldap extends Model { @@ -36,8 +35,8 @@ class Ldap extends Model } // If the user specifies where CA Certs are, make sure to use them - if(env("LDAPTLS_CACERT")) { - putenv("LDAPTLS_CACERT=".env("LDAPTLS_CACERT")); + if (env("LDAPTLS_CACERT")) { + putenv("LDAPTLS_CACERT=".env("LDAPTLS_CACERT")); } $connection = @ldap_connect($ldap_host); @@ -78,13 +77,10 @@ class Ldap extends Model $ldap_username_field = $settings->ldap_username_field; $baseDn = $settings->ldap_basedn; - if ($settings->is_ad =='1') - { - - // Check if they are using the userprincipalname for the username field. + if ($settings->is_ad =='1') { + // Check if they are using the userprincipalname for the username field. // If they are, we can skip building the UPN to authenticate against AD - if ($ldap_username_field=='userprincipalname') - { + if ($ldap_username_field=='userprincipalname') { $userDn = $username; } else { // In case they haven't added an AD domain @@ -238,7 +234,8 @@ class Ldap extends Model * @param $ldapatttibutes * @return array|bool */ - static function findLdapUsers() { + static function findLdapUsers() + { $ldapconn = Ldap::connectToLdap(); $ldap_bind = Ldap::bindAdminToLdap($ldapconn); @@ -291,8 +288,4 @@ class Ldap extends Model } - - - - } diff --git a/app/Models/License.php b/app/Models/License.php index 56422b6bda..6828cccbcc 100755 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -35,7 +35,7 @@ class License extends Depreciable public function setExpirationDateAttribute($value) { - if($value == '' || $value == '0000-00-00') { + if ($value == '' || $value == '0000-00-00') { $value = null; } $this->attributes['expiration_date'] = $value; @@ -43,7 +43,7 @@ class License extends Depreciable public function setTerminationDateAttribute($value) { - if($value == '' || $value == '0000-00-00') { + if ($value == '' || $value == '0000-00-00') { $value = null; } $this->attributes['termination_date'] = $value; @@ -261,8 +261,8 @@ class License extends Depreciable ->orWhereHas('manufacturer', function ($query) use ($search) { $query->where(function ($query) use ($search) { $query->where('manufacturers.name', 'LIKE', '%'.$search.'%'); - }); - }) + }); + }) ->orWhereHas('company', function ($query) use ($search) { $query->where(function ($query) use ($search) { $query->where('companies.name', 'LIKE', '%'.$search.'%'); diff --git a/app/Models/Loggable.php b/app/Models/Loggable.php index baf2086cb4..42c00c5fea 100644 --- a/app/Models/Loggable.php +++ b/app/Models/Loggable.php @@ -47,7 +47,7 @@ trait Loggable if (!is_null($this->asset_id) || isset($target)) { $log->target_type = Asset::class; $log->target_id = $this->asset_id; - } else if (!is_null($this->assigned_to)) { + } elseif (!is_null($this->assigned_to)) { $log->target_type = User::class; $log->target_id = $this->assigned_to; } diff --git a/app/Models/Setting.php b/app/Models/Setting.php index 133620b7c1..a0cbf05d2b 100755 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -51,11 +51,11 @@ class Setting extends Model { static $static_cache = null; - if (!$static_cache) { - if (Schema::hasTable('settings')) { - $static_cache = Setting::first(); - } + if (!$static_cache) { + if (Schema::hasTable('settings')) { + $static_cache = Setting::first(); } + } return $static_cache; diff --git a/app/Models/SnipeModel.php b/app/Models/SnipeModel.php index e83c0fc317..e8cf1c90a8 100644 --- a/app/Models/SnipeModel.php +++ b/app/Models/SnipeModel.php @@ -10,7 +10,7 @@ class SnipeModel extends Model // Setters that are appropriate across multiple models. public function setPurchaseDateAttribute($value) { - if($value == '') { + if ($value == '') { $value = null; } $this->attributes['purchase_date'] = $value; @@ -22,7 +22,7 @@ class SnipeModel extends Model public function setPurchaseCostAttribute($value) { $value = Helper::ParseFloat($value); - if($value == '0.0') { + if ($value == '0.0') { $value = null; } $this->attributes['purchase_cost'] = $value; @@ -30,7 +30,7 @@ class SnipeModel extends Model public function setLocationIdAttribute($value) { - if($value == '') { + if ($value == '') { $value = null; } $this->attributes['location_id'] = $value; @@ -38,7 +38,7 @@ class SnipeModel extends Model public function setCategoryIdAttribute($value) { - if($value == '') { + if ($value == '') { $value = null; } $this->attributes['category_id'] = $value; @@ -46,7 +46,7 @@ class SnipeModel extends Model public function setSupplierIdAttribute($value) { - if($value == '') { + if ($value == '') { $value = null; } $this->attributes['supplier_id'] = $value; @@ -54,7 +54,7 @@ class SnipeModel extends Model public function setDepreciationIdAttribute($value) { - if($value == '') { + if ($value == '') { $value = null; } $this->attributes['depreciation_id'] = $value; @@ -62,7 +62,7 @@ class SnipeModel extends Model public function setManufacturerIdAttribute($value) { - if($value == '') { + if ($value == '') { $value = null; } $this->attributes['manufacturer_id'] = $value; diff --git a/app/Models/User.php b/app/Models/User.php index c7fca06647..37433cba71 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -277,7 +277,8 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo ->orWhere('username', '=', $user_email); } - public static function generateEmailFromFullName($name) { + public static function generateEmailFromFullName($name) + { $username = User::generateFormattedNameFromFullName(Setting::getSettings()->email_format, $name); return $username['username'].'@'.Setting::getSettings()->email_domain; } diff --git a/app/Notifications/CheckinNotification.php b/app/Notifications/CheckinNotification.php index bfbad40d21..3ecb029a81 100644 --- a/app/Notifications/CheckinNotification.php +++ b/app/Notifications/CheckinNotification.php @@ -37,12 +37,11 @@ class CheckinNotification extends Notification public function via($notifiable) { $notifyBy = []; - if(Setting::getSettings()->slack_endpoint) { + if (Setting::getSettings()->slack_endpoint) { $notifyBy[] = 'slack'; } $item = $this->params['item']; - if ( - (method_exists($item, 'requireAcceptance') && ($item->requireAcceptance()=='1')) + if ((method_exists($item, 'requireAcceptance') && ($item->requireAcceptance()=='1')) || (method_exists($item, 'getEula') && ($item->getEula())) ) { $notifyBy[] = 'mail'; @@ -63,7 +62,7 @@ class CheckinNotification extends Notification ]; array_key_exists('note', $this->params) && $fields['Notes'] = $this->params['note']; - $attachment->title($item->name, $item->present()->viewUrl() ) + $attachment->title($item->name, $item->present()->viewUrl()) ->fields($fields); }); } diff --git a/app/Notifications/CheckoutNotification.php b/app/Notifications/CheckoutNotification.php index c0fbc5c384..5b52c48286 100644 --- a/app/Notifications/CheckoutNotification.php +++ b/app/Notifications/CheckoutNotification.php @@ -38,13 +38,12 @@ class CheckoutNotification extends Notification public function via($notifiable) { $notifyBy = []; - if(Setting::getSettings()->slack_endpoint) { + if (Setting::getSettings()->slack_endpoint) { $notifyBy[] = 'slack'; } $item = $this->params['item']; - if ( - (method_exists($item, 'requireAcceptance') && ($item->requireAcceptance()=='1')) + if ((method_exists($item, 'requireAcceptance') && ($item->requireAcceptance()=='1')) || (method_exists($item, 'getEula') && ($item->getEula())) ) { $notifyBy[] = 'mail'; @@ -68,7 +67,7 @@ class CheckoutNotification extends Notification ]; array_key_exists('note', $this->params) && $fields['Notes'] = $this->params['note']; - $attachment->title($item->name, $item->present()->viewUrl() ) + $attachment->title($item->name, $item->present()->viewUrl()) ->fields($fields); }); } diff --git a/app/Policies/AssetPolicy.php b/app/Policies/AssetPolicy.php index c4a72e178f..3b7574d099 100644 --- a/app/Policies/AssetPolicy.php +++ b/app/Policies/AssetPolicy.php @@ -41,7 +41,7 @@ class AssetPolicy return $user->hasAccess('assets.view'); } - public function viewRequestable(User $user, Asset $asset=null) + public function viewRequestable(User $user, Asset $asset = null) { return $user->hasAccess('assets.view.requestable'); } @@ -77,5 +77,4 @@ class AssetPolicy { return $user->hasAccess('assets.edit'); } - } diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php index 77c1049288..b04ecd6ebe 100644 --- a/app/Policies/UserPolicy.php +++ b/app/Policies/UserPolicy.php @@ -70,7 +70,7 @@ class UserPolicy */ public function delete(User $user, User $targetUser = null) { - if($targetUser) { + if ($targetUser) { //We can't delete ourselves. if ($user->id == $targetUser->id) { return false; diff --git a/app/Presenters/AccessoryPresenter.php b/app/Presenters/AccessoryPresenter.php index 0e8b5c7997..97f7a83338 100644 --- a/app/Presenters/AccessoryPresenter.php +++ b/app/Presenters/AccessoryPresenter.php @@ -8,7 +8,6 @@ namespace App\Presenters; - use App\Helpers\Helper; use Illuminate\Support\Facades\Gate; @@ -133,7 +132,7 @@ class AccessoryPresenter extends Presenter $results = []; $results['name'] = $this->nameUrl(); $results['category'] = ''; - if($this->model->category) { + if ($this->model->category) { $results['category'] = $this->model->category->present()->nameUrl(); } $results['model_number'] = $this->model_number; diff --git a/app/Presenters/AssetModelPresenter.php b/app/Presenters/AssetModelPresenter.php index 299bb272df..6da4cbebad 100644 --- a/app/Presenters/AssetModelPresenter.php +++ b/app/Presenters/AssetModelPresenter.php @@ -8,7 +8,6 @@ namespace App\Presenters; - use App\Helpers\Helper; /** @@ -48,7 +47,7 @@ class AssetModelPresenter extends Presenter $results['model_number'] = $this->model_number; $results['numassets'] = $this->assets()->count(); $results['depreciation'] = trans('general.no_depreciation'); - if(($depreciation = $this->model->depreciation) and $depreciation->id > 0) { + if (($depreciation = $this->model->depreciation) and $depreciation->id > 0) { $results['depreciation'] = $depreciation->name.' ('.$depreciation->months.')'; } $results['category'] = $this->categoryUrl(); @@ -76,7 +75,7 @@ class AssetModelPresenter extends Presenter public function eolText() { - if($this->eol) { + if ($this->eol) { return $this->eol.' '.trans('general.months'); } return ''; @@ -101,7 +100,7 @@ class AssetModelPresenter extends Presenter */ public function nameUrl() { - return (string) link_to_route('models.show',$this->name, $this->id); + return (string) link_to_route('models.show', $this->name, $this->id); } /** @@ -110,7 +109,7 @@ class AssetModelPresenter extends Presenter */ public function imageUrl() { - if(!empty($this->image)) { + if (!empty($this->image)) { return ''; } return ''; diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.php index 8fb9e76a9e..f43a07f8e5 100644 --- a/app/Presenters/AssetPresenter.php +++ b/app/Presenters/AssetPresenter.php @@ -1,5 +1,6 @@ '; - if (($this->model->availableForCheckout())) - { + if (($this->model->availableForCheckout())) { if (Gate::allows('checkout', $this->model)) { - $inout = '' . trans('general.checkout') . ''; + $inout = '' . trans('general.checkout') . ''; } } else { if (!empty($this->model->assigned_to)) { if (Gate::allows('checkin', $this->model)) { - $inout = '' . trans('general.checkin') . ''; + $inout = '' . trans('general.checkin') . ''; } } } @@ -80,16 +83,16 @@ class AssetPresenter extends Presenter $results['status_label'] = ''; $results['assigned_to'] = ''; - if($assigned = $this->model->assigneduser) { + if ($assigned = $this->model->assigneduser) { $results['status_label'] = 'Deployed'; - $results['assigned_to'] = (string) link_to_route('users.show', $assigned->present()->fullName(), $this->assigned_to ); - } else if($this->model->assetstatus) { + $results['assigned_to'] = (string) link_to_route('users.show', $assigned->present()->fullName(), $this->assigned_to); + } elseif ($this->model->assetstatus) { $results['status_label'] = $this->model->assetstatus->name; } $results['location'] = ''; if (isset($assigned) and !empty($assignedLoc = $assigned->userloc)) { $results['location'] = $assignedLoc->present()->nameUrl(); - } else if (!empty($this->model->defaultLoc)) { + } elseif (!empty($this->model->defaultLoc)) { $results['location'] = $this->model->defaultLoc->present()->nameUrl(); } @@ -98,14 +101,14 @@ class AssetPresenter extends Presenter $results['purchase_date'] = $this->purchase_date ?: ''; $results['notes'] = $this->notes; $results['order_number'] = ''; - if(!empty($this->order_number)) { + if (!empty($this->order_number)) { $results['order_number'] = link_to_route('hardware.index', $this->order_number, ['order_number' => $this->order_number]); } $results['last_checkout'] = $this->last_checkout ?: ''; $results['expected_checkin'] = $this->expected_checkin ?: ''; $results['created_at'] = ''; - if(!empty($this->created_at)) { + if (!empty($this->created_at)) { $results['created_at'] = $this->created_at->format('F j, Y h:iA'); } $results['companyName'] = $this->companyUrl(); @@ -162,7 +165,7 @@ class AssetPresenter extends Presenter public function modelUrl() { - if($this->model->model) { + if ($this->model->model) { return $this->model->model->present()->nameUrl(); } return ''; @@ -175,13 +178,13 @@ class AssetPresenter extends Presenter public function imageUrl() { $imagePath = ''; - if($this->image && !empty($this->image)) { + if ($this->image && !empty($this->image)) { $imagePath = $this->image; - } else if ($this->model && !empty($this->model->image)) { + } elseif ($this->model && !empty($this->model->image)) { $imagePath = $this->model->image; } $url = config('app.url'); - if(!empty($imagePath)) { + if (!empty($imagePath)) { $imagePath = ""; } return $imagePath; diff --git a/app/Presenters/CategoryPresenter.php b/app/Presenters/CategoryPresenter.php index 0ce206612e..d3dbef215d 100644 --- a/app/Presenters/CategoryPresenter.php +++ b/app/Presenters/CategoryPresenter.php @@ -2,7 +2,6 @@ namespace App\Presenters; - use App\Helpers\Helper; /** diff --git a/app/Presenters/CompanyPresenter.php b/app/Presenters/CompanyPresenter.php index df523d5f5d..7bae7ffeda 100644 --- a/app/Presenters/CompanyPresenter.php +++ b/app/Presenters/CompanyPresenter.php @@ -2,7 +2,6 @@ namespace App\Presenters; - /** * Class CompanyPresenter * @package App\Presenters diff --git a/app/Presenters/ComponentPresenter.php b/app/Presenters/ComponentPresenter.php index e2517f29c7..d8ad156481 100644 --- a/app/Presenters/ComponentPresenter.php +++ b/app/Presenters/ComponentPresenter.php @@ -2,7 +2,6 @@ namespace App\Presenters; - use App\Helpers\Helper; use Illuminate\Support\Facades\Gate; diff --git a/app/Presenters/ConsumablePresenter.php b/app/Presenters/ConsumablePresenter.php index aa31cd2eff..2346d40ace 100644 --- a/app/Presenters/ConsumablePresenter.php +++ b/app/Presenters/ConsumablePresenter.php @@ -2,7 +2,6 @@ namespace App\Presenters; - use App\Helpers\Helper; use Illuminate\Support\Facades\Gate; diff --git a/app/Presenters/DepreciationPresenter.php b/app/Presenters/DepreciationPresenter.php index 5e799f0da6..c4e6c747a9 100644 --- a/app/Presenters/DepreciationPresenter.php +++ b/app/Presenters/DepreciationPresenter.php @@ -2,7 +2,6 @@ namespace App\Presenters; - use App\Helpers\Helper; /** diff --git a/app/Presenters/LicensePresenter.php b/app/Presenters/LicensePresenter.php index d76deff97e..7d6153a682 100644 --- a/app/Presenters/LicensePresenter.php +++ b/app/Presenters/LicensePresenter.php @@ -2,7 +2,6 @@ namespace App\Presenters; - use App\Helpers\Helper; use Illuminate\Support\Facades\Gate; diff --git a/app/Presenters/LocationPresenter.php b/app/Presenters/LocationPresenter.php index 5b751f6b48..3dba758a47 100644 --- a/app/Presenters/LocationPresenter.php +++ b/app/Presenters/LocationPresenter.php @@ -2,7 +2,6 @@ namespace App\Presenters; - use App\Helpers\Helper; /** diff --git a/app/Presenters/ManufacturerPresenter.php b/app/Presenters/ManufacturerPresenter.php index 5922952289..ab4cc7ad2f 100644 --- a/app/Presenters/ManufacturerPresenter.php +++ b/app/Presenters/ManufacturerPresenter.php @@ -2,7 +2,6 @@ namespace App\Presenters; - use App\Helpers\Helper; /** @@ -48,7 +47,7 @@ class ManufacturerPresenter extends Presenter */ public function nameUrl() { - return (string) link_to_route('manufacturers.show', $this->name, $this->id); + return (string) link_to_route('manufacturers.show', $this->name, $this->id); } /** diff --git a/app/Presenters/Presenter.php b/app/Presenters/Presenter.php index 877568da19..821553e022 100644 --- a/app/Presenters/Presenter.php +++ b/app/Presenters/Presenter.php @@ -2,7 +2,6 @@ namespace App\Presenters; - use App\Models\SnipeModel; abstract class Presenter @@ -27,11 +26,11 @@ abstract class Presenter { $model = $this->model; // Category of Asset belongs to model. - if($model->model) { + if ($model->model) { $model = $this->model->model; } - if($model->category) { + if ($model->category) { return $model->category->present()->nameUrl(); } return ''; @@ -51,12 +50,12 @@ abstract class Presenter return $this->model->company->present()->nameUrl(); } return ''; - } + } public function manufacturerUrl() { $model = $this->model; // Category of Asset belongs to model. - if($model->model) { + if ($model->model) { $model = $this->model->model; } @@ -68,7 +67,7 @@ abstract class Presenter public function __get($property) { - if( method_exists($this, $property)) { + if (method_exists($this, $property)) { return $this->{$property}(); } @@ -79,5 +78,4 @@ abstract class Presenter { return $this->model->$method($args); } - } diff --git a/app/Presenters/UserPresenter.php b/app/Presenters/UserPresenter.php index 0bcc9ef1de..ccc90f2c17 100644 --- a/app/Presenters/UserPresenter.php +++ b/app/Presenters/UserPresenter.php @@ -2,7 +2,6 @@ namespace App\Presenters; - use App\Helpers\Helper; use App\Models\Setting; use Illuminate\Support\Facades\Auth; @@ -38,8 +37,8 @@ class UserPresenter extends Presenter $actions .= link_to_route( 'unsuspend/user', '"', - $this->id, - ['class' => 'btn btn-default btn-sm'] + $this->id, + ['class' => 'btn btn-default btn-sm'] ); } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 4fc1d62477..501bfbbd6c 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -6,7 +6,6 @@ use Illuminate\Support\ServiceProvider; use DB; use Log; - /** * This service provider handles a few custom validation rules. * @@ -27,12 +26,11 @@ class AppServiceProvider extends ServiceProvider { // Email array validator - Validator::extend('email_array', function($attribute, $value, $parameters, $validator) { - $value = str_replace(' ','',$value); + Validator::extend('email_array', function ($attribute, $value, $parameters, $validator) { + $value = str_replace(' ', '', $value); $array = explode(',', $value); - foreach($array as $email) //loop over values - { + foreach ($array as $email) { //loop over values $email_to_validate['alert_email'][]=$email; } @@ -41,7 +39,7 @@ class AppServiceProvider extends ServiceProvider 'alert_email.*'=>trans('validation.email_array') ); - $validator = Validator::make($email_to_validate,$rules,$messages); + $validator = Validator::make($email_to_validate, $rules, $messages); if ($validator->passes()) { return true; @@ -54,9 +52,9 @@ class AppServiceProvider extends ServiceProvider // Unique only if undeleted // This works around the use case where multiple deleted items have the same unique attribute. // (I think this is a bug in Laravel's validator?) - Validator::extend('unique_undeleted', function($attribute, $value, $parameters, $validator) { + Validator::extend('unique_undeleted', function ($attribute, $value, $parameters, $validator) { - $count = DB::table($parameters[0])->select('id')->where($attribute,'=',$value)->whereNull('deleted_at')->where('id','!=',$parameters[1])->count(); + $count = DB::table($parameters[0])->select('id')->where($attribute, '=', $value)->whereNull('deleted_at')->where('id', '!=', $parameters[1])->count(); if ($count < 1) { return true; @@ -91,7 +89,7 @@ class AppServiceProvider extends ServiceProvider } } - foreach($monolog->getHandlers() as $handler) { + foreach ($monolog->getHandlers() as $handler) { $handler->setLevel($log_level); } } diff --git a/app/Providers/MacroServiceProvider.php b/app/Providers/MacroServiceProvider.php index 2b14800f0a..e77619d852 100644 --- a/app/Providers/MacroServiceProvider.php +++ b/app/Providers/MacroServiceProvider.php @@ -2,7 +2,8 @@ use Illuminate\Support\ServiceProvider; -class MacroServiceProvider extends ServiceProvider { +class MacroServiceProvider extends ServiceProvider +{ /** * Bootstrap the application services. @@ -12,9 +13,9 @@ class MacroServiceProvider extends ServiceProvider { public function boot() { // require base_path() . '/resources/macros/community_types.php'; - foreach(glob(base_path('resources/macros/*.php')) as $filename) { - require_once($filename); - } + foreach (glob(base_path('resources/macros/*.php')) as $filename) { + require_once($filename); + } } @@ -27,5 +28,4 @@ class MacroServiceProvider extends ServiceProvider { { // } - } diff --git a/resources/views/asset_maintenances/view.blade.php b/resources/views/asset_maintenances/view.blade.php index b5aebafcfb..9cef1c9d97 100644 --- a/resources/views/asset_maintenances/view.blade.php +++ b/resources/views/asset_maintenances/view.blade.php @@ -63,7 +63,7 @@ use Carbon\Carbon;
{{ trans('admin/asset_maintenances/form.start_date') }}: - start_date); ?> + start_date); ?> {{ $startDate->toDateString() }}
diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php index 9a12270333..4ddeb43792 100755 --- a/resources/views/hardware/edit.blade.php +++ b/resources/views/hardware/edit.blade.php @@ -51,9 +51,9 @@ model; ?> @endif @if (Input::old('model_id')) - + @elseif (isset($selected_model)) - + @endif @if (isset($model) && $model) @include("models/custom_fields_form",["model" => $model]) @@ -84,12 +84,12 @@ @include ('partials.forms.edit.purchase_date') @include ('partials.forms.edit.supplier') @include ('partials.forms.edit.order_number') - id && $item->assetloc) { - $currency_type = $item->assetloc->currency; - } - ?> + id && $item->assetloc) { + $currency_type = $item->assetloc->currency; + } + ?> @include ('partials.forms.edit.purchase_cost', ['currency_type' => $currency_type]) @include ('partials.forms.edit.warranty') @include ('partials.forms.edit.notes') diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index eccf174232..2861efd1e6 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -521,7 +521,7 @@ {{ $assetMaintenance->admin->present()->fullName() }} @endif - cost; ?> + cost; ?> @can('update', \App\Models\Asset::class) diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index 351a10eb37..2e786bb15a 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -414,7 +414,7 @@ @lang('general.list_all') - get(); ?> + get(); ?> @if (count($status_navs) > 0)
  •  
  • @foreach ($status_navs as $status_nav) diff --git a/resources/views/licenses/view.blade.php b/resources/views/licenses/view.blade.php index d2a943b173..cfd3e1ed50 100755 --- a/resources/views/licenses/view.blade.php +++ b/resources/views/licenses/view.blade.php @@ -106,7 +106,7 @@ @endcan - + @endforeach @endif diff --git a/resources/views/models/custom_fields_form.blade.php b/resources/views/models/custom_fields_form.blade.php index 249b279623..2cc2b01c88 100644 --- a/resources/views/models/custom_fields_form.blade.php +++ b/resources/views/models/custom_fields_form.blade.php @@ -48,7 +48,7 @@ if ($errormessage) { $errormessage=preg_replace('/ snipeit /', '', $errormessage); print(' '.$errormessage.''); - } + } ?>
    diff --git a/resources/views/reports/asset_maintenances.blade.php b/resources/views/reports/asset_maintenances.blade.php index ed780327ec..1a6e52b9d9 100644 --- a/resources/views/reports/asset_maintenances.blade.php +++ b/resources/views/reports/asset_maintenances.blade.php @@ -39,7 +39,7 @@ + ?> @foreach ($assetMaintenances as $assetMaintenance) {{ is_null($assetMaintenance->asset->company) ? '' : $assetMaintenance->asset->company->name }} @@ -65,10 +65,10 @@ {{ number_format($assetMaintenance->cost,2) }} - cost); - ?> + cost); + ?> @endforeach diff --git a/resources/views/suppliers/view.blade.php b/resources/views/suppliers/view.blade.php index c486711998..9e26369846 100755 --- a/resources/views/suppliers/view.blade.php +++ b/resources/views/suppliers/view.blade.php @@ -198,7 +198,7 @@ {{ $improvement->completion_date }} {{ $improvement->is_warranty ? trans('admin/asset_maintenances/message.warranty') : trans('admin/asset_maintenances/message.not_warranty') }} {{ sprintf( trans( 'general.currency' ) . '%01.2f', $improvement->cost) }} - cost; ?> + cost; ?> diff --git a/resources/views/vendor/notifications/email.blade.php b/resources/views/vendor/notifications/email.blade.php index 94f86a960e..b025edc4c4 100644 --- a/resources/views/vendor/notifications/email.blade.php +++ b/resources/views/vendor/notifications/email.blade.php @@ -108,16 +108,16 @@ $style = [