Replies: 6 comments
-
Should be
Otherwise it looks for an "activity_log" relation on the Activity model, which doesn't exist. |
Beta Was this translation helpful? Give feedback.
-
Thank you. It works, but I have another issue: how can I show user name?
|
Beta Was this translation helpful? Give feedback.
-
Share what you have setup in configure and the column you're trying to use for the user name If you're using builder() approach then also please share that |
Beta Was this translation helpful? Give feedback.
-
I tried with both the model approach and the builder public function builder(): Builder {
return Activity::query()
->with(['causer'])
->select();
} This is configure public function configure(): void
{
$this->setPrimaryKey('id');
$this->setDefaultSort('id', 'desc');
$this->setPerPageAccepted([25, 50, 100]);
$this->setPerPage(25);
$this->setTdAttributes(function (Column $column) {
if ($column->isField('properties')) {
return [
'default' => false,
'class' => 'w-80 text-xs',
];
}
return [];
});
$this->setDebugStatus(config('goldportal.debug'));
} This is the column Column::make('user', "causer.name"), |
Beta Was this translation helpful? Give feedback.
-
If you use a label, then you'll be able to do it Keep in mind that ActivityLog being a morphTo, you'll have an n+1 query. But it'll only be the two queries running |
Beta Was this translation helpful? Give feedback.
-
I am not sure to understand. Do you mean something like this? Column::make('user',"causer_id")
->label(fn($row) => User::find($row->causer_id)->name), |
Beta Was this translation helpful? Give feedback.
-
What happened?
The table component does not work with Activity model by spatie nor with a builder query
How to reproduce the bug
Package Version
3.4.17
PHP Version
8.1.x
Laravel Version
10.48
Alpine Version
No response
Theme
None
Notes
Error Message
Call to undefined relationship [activity_log] on model [Spatie\Activitylog\Models\Activity].
https://flareapp.io/share/Lm8lKa1m
Beta Was this translation helpful? Give feedback.
All reactions