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

Add docs for new Path Enumerable trait #227

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

Conversation

bennothommo
Copy link
Member


Method | Description
------ | -----------
`->getParent()` | Gets the parent record of the current record, if one exists. Returns a `Collection` with zero or one parent record. This is similar to the `parent` relation.
Copy link
Member

Choose a reason for hiding this comment

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

Why does this return a collection instead of a single instance?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question - might have to check that. I just went off the signature of the method. Might be PHPStan related?

// ...

// Defines the column used for storing the parent ID.
const PARENT_ID = 'parent_id';
Copy link
Member

Choose a reason for hiding this comment

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

Is it an absolute hard requirement that we have a parent_id column? Is there anyway at all that we could use some magic to eliminate the need for the parent_id column and just rely on the structure of the path column? I'm not familiar with the inner workings of the code at the moment

Copy link
Member

Choose a reason for hiding this comment

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

My thoughts being that I really want the filesystem itself to remain the single source of truth, the purpose of the database layer is to provide an easy way to manage additional metadata on the individual files as well as make it easier to improve performance.

Copy link
Member Author

@bennothommo bennothommo Jan 28, 2025

Choose a reason for hiding this comment

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

Having the parent ID would give us a recovery process if the hierarchy got corrupted - we'd be able to reconstruct all the paths based off the parent IDs. It's also used to determine if the record has actually moved or not (and ensuring that we have the correct path of the parent when moving the record to formulate the path of the current record and anything underneath - see the moveToNewParent method in the trait PR for more info on that)

While this trait is mainly for the media library changes, it can most certainly be used for other things, so I don't think we should necessarily be too "strict" about designing this around our requirements for the media library.

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