rmsramos/activitylog

Error when model/user is on softdelete

Opened this issue · 0 comments

Package Version

3.1

Laravel Version

11

PHP Version

8.2

Problem description

i have seen another error on the plugin, if the causer->name is on softdelete it will have null error

You can fix it like this
public static function getCauserNameColumnCompoment(): Column
{
return TextColumn::make('causer.name')
->label(__('activitylog::tables.columns.causer.label'))
->getStateUsing(function (Model $record) {

            if ($record->causer_id == null) {
                return new HtmlString('—');
            }

            return $record->causer->name ?? '';
        })
        ->placeholder( 'Record deleted' )
        ->searchable();
}

Expected behavior

Should have placeholder or something

Steps to reproduce

softdelete a model/user or add a deleted_at date

Reproduction repository (issue will be closed if this is not valid)

https://github.com/dharen008/Vendors.git

Relevant log output

No response