Export fails when query has with relation

This serialize facade used in the exporter errors ungracefully if there are any ->with('relation') on the query. Taken a while to figure out what was happening.
$serializedQuery = EloquentSerializeFacade::serialize($query);
$serializedQuery = EloquentSerializeFacade::serialize($query);
It references this package and there are others with similar problems.
https://github.com/AnourValar/eloquent-serialize/issues?q=relation
GitHub
Issues · AnourValar/eloquent-serialize
Contribute to AnourValar/eloquent-serialize development by creating an account on GitHub.
1 Reply
acroninja
acroninjaOP2mo ago
In case anyone else has the problem, a workaround is to remove eager loaded relations on the exporter like this:-
public static function modifyQuery(Builder $query): Builder
{
$query->setEagerLoads([]);
return $query;
}
public static function modifyQuery(Builder $query): Builder
{
$query->setEagerLoads([]);
return $query;
}
Want results from more Discord servers?
Add your server