Guard against null values in the reports generator. May fix #2758 (#2762)

This commit is contained in:
Daniel Meltzer 2016-10-12 14:06:38 -05:00 committed by snipe
parent 2e0a7abbe9
commit 8e60767c00

View file

@ -367,14 +367,30 @@ class ReportsController extends Controller
if (($activity->user) && ($activity->action_type=="uploaded") && ($activity->itemType()=="user")) {
$activity_target = '<a href="'.route('view/user', $activity->target_id).'">'.$activity->user->fullName().'</a>';
} elseif (($activity->item) && ($activity->target_type === "App\Models\Asset")) {
} elseif ($activity->target_type === "App\Models\Asset") {
if($activity->target) {
$activity_target = '<a href="'.route('view/hardware', $activity->target_id).'">'.$activity->target->showAssetName().'</a>';
} else {
$activity_target = "Unknown Item";
}
} elseif ( $activity->target_type === "App\Models\User") {
if($activity->target()) {
$activity_target = '<a href="'.route('view/user', $activity->target_id).'">'.$activity->target->fullName().'</a>';
} else {
$activity_target = 'Unknown User';
}
} elseif ($activity->action_type=='requested') {
if ($activity->user) {
$activity_target = '<a href="'.route('view/user', $activity->user_id).'">'.$activity->user->fullName().'</a>';
} else {
$activity_target = 'Unknown User';
}
} else {
if($activity->target) {
$activity_target = $activity->target->id;
} else {
$activity_target = "Unknown";
}
}