From 108727c5005c63afba18db58e21b3f68edab761b Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 28 Jun 2024 01:48:11 -0500 Subject: [PATCH] Handle missing device when linking (#16164) * Handle missing device when linking Sometimes a device is gone, but data still points to it. Prevent error when that happens (even though it should not) * Handle more gracefully * Remove original work around * Allow unsaved devices, we just need device_id really --- app/View/Components/DeviceLink.php | 4 ++++ resources/views/components/device-link-missing.blade.php | 1 + 2 files changed, 5 insertions(+) create mode 100644 resources/views/components/device-link-missing.blade.php diff --git a/app/View/Components/DeviceLink.php b/app/View/Components/DeviceLink.php index 1f17cd3c52..88a7ef66cb 100644 --- a/app/View/Components/DeviceLink.php +++ b/app/View/Components/DeviceLink.php @@ -46,6 +46,10 @@ class DeviceLink extends Component */ public function render() { + if (empty($this->device->device_id)) { + return view('components.device-link-missing'); + } + if (! $this->device->canAccess(auth()->user())) { return view('components.device-link-no-access'); } diff --git a/resources/views/components/device-link-missing.blade.php b/resources/views/components/device-link-missing.blade.php new file mode 100644 index 0000000000..93ca902456 --- /dev/null +++ b/resources/views/components/device-link-missing.blade.php @@ -0,0 +1 @@ +{{ $slot->isNotEmpty() ? $slot : '' }}