8000 custom Causer name column · Issue #63 · rmsramos/activitylog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

custom Causer name column #63

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

Open
hatimox opened this issue Oct 23, 2024 · 2 comments
Open

custom Causer name column #63

hatimox opened this issue Oct 23, 2024 · 2 comments
Labels
bug Something isn't working unconfirmed

Comments

@hatimox
Copy link
hatimox commented Oct 23, 2024

Package Version

v1.0

Laravel Version

v11

PHP Version

php 8.3

Problem description

i have a custom users table that doesn't contain a Name Column , so the user name column and the user name field are empty on the table and the form , any way to define what proverty should be used as a causer name to avoid customization of full resources ?

Expected behavior

have a method on the causer model to get the causer attribute that i want to show or a combination of attributes

Steps to reproduce

install the package and change the column name of the User Model and try

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

https://github.com

Relevant log output

No response

@hatimox hatimox added bug Something isn't working unconfirmed labels Oct 23, 2024
@phitnetwork
Copy link
phitnetwork commented Jan 24, 2025

Same here.

I've a User table that i don't want to use to log the activities, beside, i've the "Employee" class for the users.
What is needed is something that can let us choose the user model instead of the default one or to customize the information of the causer (i can make my own funcs to get the info, but i need to understand where i can inject them).

For example for the view activty i've used:
TextInput::make('causer_id') ->afterStateHydrated(function ($component, ?Model $record) { /** @phpstan-ignore-next-line */ $employee = $record->causer->getEmployee(); return $component->state($employee->full_name); }) ->label(__('activitylog::forms.fields.causer.label')),

but i've problem in understanding how to do it in the infolist timeline and probably also in the relation manager

@CyberLine
Copy link
Contributor

Just implement this method in your User Model:

public function getNameAttribute(): string
{
    return $this->firstname . ' ' . $this->lastname;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed
Projects
None yet
Development

No branches or pull requests

3 participants
0