livewire-datatables icon indicating copy to clipboard operation
livewire-datatables copied to clipboard

Multiple relationship with same table is showing wrong values

Open amit-viacon opened this issue 4 years ago • 5 comments

This fileds are fetching two different relationships

Column::name('assignedBy.first_name')->label('Assigned by')->alignCenter(),
Column::name('assignedTo.first_name')->label('Assigned to')->alignCenter(),

Both data is coming from same table (users)

public function assignedBy()
{
    return $this->belongsTo(User::class);
}

public function assignedTo()
{
    return $this->belongsTo(User::class);
}

Problem: The data-table is showing same value on both places

select `tasks`.`id` as `id`, `users`.`first_name` as `assignedBy.first_name`, `users`.`first_name` as `assignedTo.first_name` from `tasks` left join `users` on `tasks`.`assigned_by_id` = `users`.`id` where `tasks`.`deleted_at` is null order by `id` desc limit 10 offset 0

Note

#257 is more of an hack and not "a fix".

This issues is still there on the package. And it is clearly not an expected behaviour based on how the package configurations work.

amit-viacon avatar Aug 25 '21 06:08 amit-viacon

It's still wrong. Please, fix it

sort72 avatar Mar 25 '22 15:03 sort72

This packages is dead. It is having so many issues and almost no attention from its creator.

Move on.

amit-viacon avatar Mar 28 '22 05:03 amit-viacon

@amit-viacon, this package is wonderful and free, If you have any issue using it. Kindly make a PR and make it great again?

Plus, Why do you create the same relation in 2 different methods?

ousid avatar May 28 '22 15:05 ousid

I agree that the original maintainer of this package is unfortunately not active anymore. This package still is great for many purposes and i will happily merge incoming bug fixes and improvements.

The only "alternative" i know of is https://filamentphp.com/docs/2.x/tables/installation , but its inside the filament universe. (which is a fine universe, if you are doing a backend for your project).

thyseus avatar May 29 '22 05:05 thyseus

us, Why do you create the same relation in 2 different methods?

@ousid

I have already shown the example. AssignedTo and AssignedBy both are coming from the users table.

I am currently using and maintaining https://github.com/rappasoft/laravel-livewire-tables

amit-viacon avatar May 31 '22 06:05 amit-viacon