This commit is contained in:
pbao9
2026-02-01 10:27:56 +07:00
parent ef112ee7f6
commit b3ad727d55
6 changed files with 55 additions and 19 deletions
@@ -40,11 +40,16 @@ class DatastoreRepository extends BaseRepository implements DatastoreRepositoryI
{
$model = $this->model;
if (count($relationships) > 0) {
$validRelationships = [];
foreach ($relationships as $relationship) {
if (method_exists($model, $relationship)) {
$model = $model->with($relationship);
$firstRelation = explode('.', $relationship)[0];
if (method_exists($model, $firstRelation)) {
$validRelationships[] = $relationship;
}
}
if (count($validRelationships) > 0) {
$model = $model->with($validRelationships);
}
}
// Xử lý withCount