Skip to content

[Bug]: Problem with multiple columns against same table but different relationships (columns) #2275

Open
@emiliosh

Description

@emiliosh

What happened?

Hi, someone has issued this last year #1778 but he doesn't give additional info.

My class.

class WorkPlaceReserved extends BaseModel
{
.....
    public function motivestarted()
    {
        return $this->belongsTo(WorkPlaceReservedMotive::class, 'startmotive_id');
    }

    public function motiveended()
    {
        return $this->belongsTo(WorkPlaceReservedMotive::class, 'endmotive_id');
    }
.....
}

My table.

class WorkplaceReservedTable extends BaseDataTableComponent
{
.....
    public function columns(): array
    {
        return [
            Column::make('#Reserva', 'id')->formatRoute('workplace-reserved'),
            Column::make('#Ocupación', 'tenure_id')->formatRoute('tenure'),
            Column::make('Motivo Ini', 'motivestarted.name'),
            Column::make('Motivo Fin', 'motiveended.name'),
            Column::make('Fecha Ini', 'started_at')->formatDate(),
            Column::make('Fecha Fin', 'ended_at')->formatDate(),
        ];
    }
.....
}

The problem is DataTable show in the second column same value as first one.

I guess someone else have experienced it.

How to reproduce the bug

Just create a model who relates to same table against two different relations.

Package Version

Rappasoft versión v2.15.0

Livewire v2.12.8

PHP Version

PHP 8.3

Laravel Version

Laravel v9.52.20

Alpine Version

AlpineJS v3.13.7

Theme

TailwindCSS

Notes

No response

Error Message

No error just show the same value of the first column.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions