© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•13mo ago•
1 reply
sprac

Using accessor in RelationManager AttachAction not working

I have following database structure:

User
- email
- person_id

Person
- firstname
- lastname

and I have created an accessor in my User model:
protected $with = ['person'];

public function person()
    {
        return $this->belongsTo(Person::class);
    }

public function name(): Attribute
    {
        return Attribute::make(
            get: fn () => "{$this->person->firstname} {$this->person->lastname}",
        );
    }
protected $with = ['person'];

public function person()
    {
        return $this->belongsTo(Person::class);
    }

public function name(): Attribute
    {
        return Attribute::make(
            get: fn () => "{$this->person->firstname} {$this->person->lastname}",
        );
    }


My RelationManager:
class UserRelationManager extends RelationManager
{
    protected static string $relationship = 'users';

    public static function getRecordTitleAttribute(): ?string
    {
        return 'name';
    }

    ....

    ->headerActions([
                AttachAction::make(),
            ])
class UserRelationManager extends RelationManager
{
    protected static string $relationship = 'users';

    public static function getRecordTitleAttribute(): ?string
    {
        return 'name';
    }

    ....

    ->headerActions([
                AttachAction::make(),
            ])


and I expect that this accessor will be used in the RelationshipManager, but it is not.

When trying to add a User to a Role I have this error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.name' in 'where clause' (Connection: mysql, SQL: select distinct `users`.* from `users` left join `model_has_roles` on `users`.`id` = `model_has_roles`.`model_id` where (`users`.`name` like %myName%) and not exists (select * from `roles` inner join `model_has_roles` on `roles`.`id` = `model_has_roles`.`role_id` where `users`.`id` = `model_has_roles`.`model_id` and `model_has_roles`.`model_type` = App\Models\User and `roles`.`id` = 1) order by `users`.`name` asc limit 50)
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.name' in 'where clause' (Connection: mysql, SQL: select distinct `users`.* from `users` left join `model_has_roles` on `users`.`id` = `model_has_roles`.`model_id` where (`users`.`name` like %myName%) and not exists (select * from `roles` inner join `model_has_roles` on `roles`.`id` = `model_has_roles`.`role_id` where `users`.`id` = `model_has_roles`.`model_id` and `model_has_roles`.`model_type` = App\Models\User and `roles`.`id` = 1) order by `users`.`name` asc limit 50)
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

AttachAction in relationManager
FilamentFFilament / ❓┊help
14mo ago
RelationManager ->table ->attachAction
FilamentFFilament / ❓┊help
3y ago
RelationManager Not working
FilamentFFilament / ❓┊help
3y ago
AttachAction not working for custom select
FilamentFFilament / ❓┊help
3y ago