Anyway of displaying a deleted relation name in the table builder?

I've tried disabling the global scope, modifying the table query to pull the relation with trashed. The relation is a belongs to many (if that changes anything) TextColumn::make('teams.nome') ->placeholder('N.D.') ->label('Instituição')
6 Replies
Mohamed Ayaou
Mohamed Ayaou5d ago
not sure but I think you may edit the relation in the Models/Team itself to includeTrashed maybe
Firebat
FirebatOP5d ago
i tried, didnt work :/ i was thinking about making included when getting the user
Mohamed Ayaou
Mohamed Ayaou5d ago
You might then override the global query builder of your resource to add a ->with(['teams'=> ...]) the query here will include the witTrashed maybe
Firebat
FirebatOP5d ago
tried that one too, but i may be wrong be cause i did $query->teams()->withTrashed() maybe i should have done with ->with(['teams' => trashed()]) like you said
Mohamed Ayaou
Mohamed Ayaou5d ago
I think it will be something like:
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
])
->with('teams', fn ($query) => query->withTrashed);
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
])
->with('teams', fn ($query) => query->withTrashed);
}
this is an override of the resource getEloquentQuery method edit this ->with(['teams' => trashed()]) to ->with(['teams' => fn($query)=> $query->withTrashed()]) and try
Firebat
FirebatOP5d ago
well, thanks to you i founded a "bug" in my code quite funny that is happening a ->after() that i deleted a long time ago that detached all the users from the team but it only happens in the one in the table not the one in the editpage but, this didnt work

Did you find this page helpful?