Skip to content

[Fixed] Accessors are not working on "Multi fields" using ".keyword" #11

@alirezaImani79

Description

@alirezaImani79

Describe the bug

I have a model named Audit and it has a auditable_type field which is multi field with types keyword and text .
I tried to use accessors to format the retrevived auditable_type and realized that accessors are not working . even accessor function did not called .

Audit.php

<?php

...

class Audit extends Model
{
    ...

    public function getAuditableTypeAttribute(string $value)
    {
        return collect(array_filter(explode('\\', $value), function ($item) {
            return $item != null && $item != '';
        }))->last();
    }


}

AuditRepository.php

$column = "auditable_type.keyword";
Audit::distinct($column)->get($column)->pluck([$column]); // we expect that accessor format the field .

To Reproduce

Create a model using laravel-elasticsearch package and try to implement an accessor for a text field .

Expected behavior

We Expect that model accessor format the desired field correctly .

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions