Catch weird edge case where target wouldn’t have an ID (?!)

This commit is contained in:
snipe 2020-04-09 20:23:02 -07:00
parent 7ebd21bc04
commit cf9d0201e0
No known key found for this signature in database
GPG key ID: 10BFFDA3ED34B5AC

View file

@ -45,9 +45,15 @@ trait Loggable
$log->user_id = Auth::user()->id;
if (!isset($target)) {
throw new Exception('All checkout logs require a target');
throw new Exception('All checkout logs require a target.');
return;
}
if (!isset($target->id)) {
throw new Exception('That target seems invalid (no target ID available).');
return;
}
$log->target_type = get_class($target);
$log->target_id = $target->id;