Eager load issue

I have a relation manager with eager load, i am using dot notation for the values, for some reason the data in a table shows in one row, instead of having a new row for each related data. Any help?
public function table(Table $table): Table
{
return $table
->emptyStateHeading('No Subscriptions Found')
->modifyQueryUsing(fn(Builder $query) => $query->whereHas('subscriptions'))
->columns([
Tables\Columns\TextColumn::make('subscriptions.stripe_id')
->label('Subscribe ID')
->badge()
->copyable(),
])
->filters([
//
])
->headerActions([
//Tables\Actions\CreateAction::make(),
]);
}
public function table(Table $table): Table
{
return $table
->emptyStateHeading('No Subscriptions Found')
->modifyQueryUsing(fn(Builder $query) => $query->whereHas('subscriptions'))
->columns([
Tables\Columns\TextColumn::make('subscriptions.stripe_id')
->label('Subscribe ID')
->badge()
->copyable(),
])
->filters([
//
])
->headerActions([
//Tables\Actions\CreateAction::make(),
]);
}
No description
Solution:
What you want is probably a left join to actually get multiple rows instead of eager loading a relation ship (which gives you a collection on every row)
Jump to solution
5 Replies
kingtox
kingtoxOP8mo ago
bump
Dennis Koch
Dennis Koch8mo ago
Uhm. It’s a „column“ so it shows your values in one column. That’s how it’s intended. If you want to show different data you need to adjust the query.
kingtox
kingtoxOP8mo ago
i want to show array data in each single row, right now it shows everything in one row. so adjusting query will resolve the issue? if so could you please share some more information?
Solution
Dennis Koch
Dennis Koch8mo ago
What you want is probably a left join to actually get multiple rows instead of eager loading a relation ship (which gives you a collection on every row)
kingtox
kingtoxOP8mo ago
Perfect, let me try left join Thank you so much, left join resolve the issue.
Want results from more Discord servers?
Add your server