laravel-livewire-tables: [2.0] Relationship error
There is a problem when you have two relationships with the same table it always shows the first relationship. I’ll try to explain:
I have a model like this:
class Employee extends Model
{
...
public function company(): BelongsTo
{
return $this->belongsTo(Company::class, 'company_id', 'id');
}
public function related_company(): BelongsTo
{
return $this->belongsTo(Company::class, 'related_company_id', 'id');
}
...
}
I have a UserTable component with this piece of code
...
Column::make("Id", "id"),
Column::make("Com. Id.", "company_id"),
Column::make("Company", "company.name"),
Column::make("Rel. Id.", "related_company_id"),
Column::make("Rel. Company", "related_company.name"),
...
It shows something like this…

The last column in the first line shows “Company 3” when related_company_id = 2. If I remove two first lines, I have something like this
In this case, the column shows the correct value of the related table.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 21 (6 by maintainers)
Have you tried as workaround:
Hello, I have exactly the same problem. I need to show 3 users who participate in the approval of some documents, by stages, but it only shows the first one in the 3 columns. Has anyone been able to solve the problem???
Hello, how can I call a data from my related table, it does not work as the documentation says
my function :
the error
Rappasoft\LaravelLivewireTables\Views\Column::setTable(): Argument #1 ($table) must be of type string, null given, called in C:\laragon\www\appema\vendor\rappasoft\laravel-livewire-tables\src\Traits\Helpers\ColumnHelpers.php on line 24help me please
Thank you