Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit 7619160

Browse files
committed
Solved bug when the BelongsTo value is null
1 parent f3cb0a3 commit 7619160

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Fields/BelongsTo.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ private function getOriginalValueEdit($model) {
122122

123123
$item = $model[$this->data->get('column')];
124124

125+
if (!$item) return null;
126+
125127
return [
126128
'key' => $item[$query->getOwnerKeyName()],
127129
'value' => $item[$this->data->get('display_column')]
@@ -136,6 +138,8 @@ private function getOriginalValueShow($model) {
136138
$query = $model->{$this->data->get('column')}();
137139
$item = $model[$this->data->get('column')];
138140

141+
if (!$item) return null;
142+
139143
return [
140144
'key' => $item[$query->getOwnerKeyName()],
141145
'value' => $item[$this->data->get('display_column')]
@@ -176,6 +180,8 @@ private function getTranslatedValueEdit($model) {
176180

177181
$item = $model[$this->data->get('column')];
178182

183+
if (!$item) return null;
184+
179185
return [
180186
'key' => $item[$query->getOwnerKeyName()],
181187
'value' => $item->getTranslated($this->data->get('display_column'), request()->input('lang'))
@@ -190,6 +196,8 @@ private function getTranslatedValueShow($model) {
190196
$query = $model->{$this->data->get('column')}();
191197
$item = $model[$this->data->get('column')];
192198

199+
if (!$item) return null;
200+
193201
return [
194202
'key' => $item[$query->getOwnerKeyName()],
195203
'value' => $item->getTranslated($this->data->get('display_column'), request()->input('lang'))

0 commit comments

Comments
 (0)