Skip to content

Commit 48c5f68

Browse files
Muchwatrmsramos
authored andcommitted
Fix: Handle null causer in getCauserNameColumnCompoment
This PR fixes an issue where accessing the `causer` relationship throws an error when the `causer` is deleted or `null`.
1 parent b6e0998 commit 48c5f68

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Resources/ActivitylogResource.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,12 @@ public static function getCauserNameColumnComponent(): Column
224224
return TextColumn::make('causer.name')
225225
->label(__('activitylog::tables.columns.causer.label'))
226226
->getStateUsing(function (Model $record) {
227-
228-
if ($record->causer_id == null) {
227+
// Check if causer is null or causer_id is null
228+
if ($record->causer_id == null || $record->causer == null) {
229229
return new HtmlString('—');
230230
}
231231

232+
// Return the causer's name if causer exists
232233
return $record->causer->name;
233234
})
234235
->searchable();

0 commit comments

Comments
 (0)