laravel-livewire-tables icon indicating copy to clipboard operation
laravel-livewire-tables copied to clipboard

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

Open emiliosh opened this issue 5 months ago • 0 comments

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.

emiliosh avatar Jun 02 '25 12:06 emiliosh