Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Handle nested relations #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

liam-wiltshire
Copy link
Owner

No description provided.

@mathieutu
Copy link

Hi @liam-wiltshire.
I had this issue again, more than one year after!

I've tested your piece of code and actual.. it works pretty well!
5 uniques queries, instead of 131 during my tests!

The only thing I see is that it adds a callerin the relation, and if the relation is a unique model, it adds it in its attributes. I'll make you some suggestion to avoid that.

Comment on lines +27 to 29
public $parentCollection = null;

/**

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public $parentCollection = null;
/**
public $parentCollection = null;
public $caller;
/**

Comment on lines +136 to 138
$collection = $this->relations[$method];
$collection->caller = (object) ['method' => $method, 'model' => $this];
return $this->relations[$method];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$collection = $this->relations[$method];
$collection->caller = (object) ['method' => $method, 'model' => $this];
return $this->relations[$method];
$relation = $this->relations[$method];
$relation->caller = (object) ['method' => $method, 'model' => $this];
return $relation;

@@ -112,7 +112,9 @@ private function logAutoload(string $relationship)
*/
public function getRelationshipFromMethod($method)
{
$fqRelation = "";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$fqRelation = "";

@mathieutu
Copy link

mathieutu commented Mar 2, 2023

Hey @liam-wiltshire, I'm working on a Laravel project again after a few years break, and I found this open PR. 😅
Do you think we can merge it?
(BTW is this package still maintained? I'm seeing no commit since 2020, and not compatible with last Laravel versions..)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants