MedicOneSystems / livewire-datatables

Advanced datatables using Laravel, Livewire, Tailwind CSS and Alpine JS
https://livewire-datatables.com/
MIT License
1.2k stars 258 forks source link

Multiple relationship with same table is showing wrong values #270

Open amit-viacon opened 3 years ago

amit-viacon commented 3 years ago

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.

sort72 commented 2 years ago

It's still wrong. Please, fix it

amit-viacon commented 2 years ago

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

Move on.

ousid commented 2 years ago

@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?

thyseus commented 2 years ago

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).

amit-viacon commented 2 years ago

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