Merge pull request #12631 from snipe/bug/sc-20297/expected-checkin-email-report-link-back-error

Dynamically determine target route for expected checkin emails
This commit is contained in:
snipe 2023-03-07 13:57:26 -08:00 committed by GitHub
commit 182a5ea5fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View file

@ -547,6 +547,28 @@ class Asset extends Depreciable
return strtolower(class_basename($this->assigned_type)); return strtolower(class_basename($this->assigned_type));
} }
/**
* This is annoying, but because we don't say "assets" in our route names, we have to make an exception here
* @todo - normalize the route names - API endpoint URLS can stay the same
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v6.1.0]
* @return string
*/
public function targetShowRoute()
{
$route = str_plural($this->assignedType());
if ($route=='assets') {
return 'hardware';
}
return $route;
}
/** /**
* Get the asset's location based on default RTD location * Get the asset's location based on default RTD location
* *

View file

@ -10,7 +10,7 @@
@php @php
$checkin = Helper::getFormattedDateObject($asset->expected_checkin, 'date'); $checkin = Helper::getFormattedDateObject($asset->expected_checkin, 'date');
@endphp @endphp
| [{{ $asset->present()->name }}]({{ route('hardware.show', ['hardware' => $asset->id]) }}) | [{{ $asset->assigned->present()->fullName }}]({{ route('users.show', ['user'=>$asset->assigned->id]) }}) | {{ $checkin['formatted'] }} | [{{ $asset->present()->name }}]({{ route('hardware.show', ['hardware' => $asset->id]) }}) | [{{ $asset->assigned->present()->fullName }}]({{ route($asset->targetShowRoute().'.show', [$asset->assigned->id]) }}) | {{ $checkin['formatted'] }}
@endforeach @endforeach
@endcomponent @endcomponent