From 0a218a37d05311e8f91ab72113852b449818c893 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 29 Sep 2016 10:32:09 -0700 Subject: [PATCH 1/3] Check that the user exists before trying to get location id --- app/Http/Controllers/ReportsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index dcc93e0341..f1ac2b7b66 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -518,7 +518,7 @@ class ReportsController extends Controller } if (e(Input::get('location')) == '1') { $show_loc = ''; - if (( $asset->assigned_to > 0 ) && ( $asset->assigneduser->location_id !='' )) { + if (( $asset->assigned_to > 0 ) && ( $asset->assigneduser) && ( $asset->assigneduser->location_id !='' )) { $location = Location::find($asset->assigneduser->location_id); if ($location) { $show_loc .= '"' .e($location->name). '"'; From b41883c1259c4e4edf5fe4cce05d628951e69e96 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 29 Sep 2016 11:37:38 -0700 Subject: [PATCH 2/3] Use user object to prevent errors on deleted users --- app/Http/Controllers/ReportsController.php | 24 ++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index f1ac2b7b66..6b83c0f14a 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -516,15 +516,13 @@ class ReportsController extends Controller $row[] = ''; } } + if (e(Input::get('location')) == '1') { $show_loc = ''; - if (( $asset->assigned_to > 0 ) && ( $asset->assigneduser) && ( $asset->assigneduser->location_id !='' )) { - $location = Location::find($asset->assigneduser->location_id); - if ($location) { - $show_loc .= '"' .e($location->name). '"'; - } else { - $show_loc .= 'User location '.$asset->assigneduser->location_id.' is invalid'; - } + + + if (($asset->assigned_to > 0) && ($asset->assigneduser) && ($asset->assigneduser->location)) { + $show_loc .= '"' .e($asset->assigneduser->location->name). '"'; } elseif ($asset->rtd_location_id!='') { $location = Location::find($asset->rtd_location_id); if ($location) { @@ -537,19 +535,19 @@ class ReportsController extends Controller $row[] = $show_loc; } + + if (e(Input::get('assigned_to')) == '1') { - if ($asset->assigned_to > 0) { - $user = User::find($asset->assigned_to); - $row[] = '"' .e($user->fullName()). '"'; + if ($asset->assigneduser) { + $row[] = '"' .e($asset->assigneduser->fullName()). '"'; } else { $row[] = ''; // Empty string if unassigned } } if (e(Input::get('username')) == '1') { - if ($asset->assigned_to > 0) { - $user = User::find($asset->assigned_to); - $row[] = '"' .e($user->username). '"'; + if ($asset->assigneduser) { + $row[] = '"' .e($asset->assigneduser->username). '"'; } else { $row[] = ''; // Empty string if unassigned } From d7434797ec47d2169fd7caea944924f85a12dabe Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 19 Oct 2016 14:59:28 -0700 Subject: [PATCH 3/3] Change order number to string in components table --- ...x_order_number_in_components_to_string.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 database/migrations/2016_10_19_145520_fix_order_number_in_components_to_string.php diff --git a/database/migrations/2016_10_19_145520_fix_order_number_in_components_to_string.php b/database/migrations/2016_10_19_145520_fix_order_number_in_components_to_string.php new file mode 100644 index 0000000000..c08131d922 --- /dev/null +++ b/database/migrations/2016_10_19_145520_fix_order_number_in_components_to_string.php @@ -0,0 +1,31 @@ +string('order_number')->nullable()->default(null)->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('components', function ($table) { + $table->integer('order_number')->nullable()->default(null)->change(); + }); + } +}