-
-
Notifications
You must be signed in to change notification settings - Fork 337
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Cannot use table with Spatie Laravel-activitylog #1931
Comments
Should be
Otherwise it looks for an "activity_log" relation on the Activity model, which doesn't exist. |
Thank you. It works, but I have another issue: how can I show user name?
|
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 |
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"), |
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 |
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), |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
The text was updated successfully, but these errors were encountered: