diff --git a/CHANGELOG.md b/CHANGELOG.md index f267a92..407e8a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [4.5.4] - 27-02-2024 + +### Changed + +- Fixed issue with (soft-)deleted models throwing an exception when rendering field + ## [4.5.3] - 27-02-2024 ### Changed diff --git a/src/Multiselect.php b/src/Multiselect.php index 8f5e338..5a52175 100644 --- a/src/Multiselect.php +++ b/src/Multiselect.php @@ -384,7 +384,7 @@ public function setOptionsFromModels(Collection $models, $resourceClass) $models ->mapInto($resourceClass) ->mapWithKeys(function ($associatedResource) { - $keyName = $this->keyName ?? $associatedResource->getKeyName() ?? null; + $keyName = $this->keyName ?? ($associatedResource ? $associatedResource->getKeyName() : null); if (!$keyName) return null; $resourceKey = $associatedResource->{$keyName};