You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for scope classes in relation attributes to allow for more complex and reusable query conditions in entity relationships.
Problem
Currently, CycleORM allows defining relationships for an entity using attributes, but there's no built-in way to add additional conditions or complex queries using these attributes. This limitation makes it difficult to handle scenarios where more specific criteria are needed for relationship resolution, such as selecting the latest record or applying custom filtering.
Proposed Solution
Introduce a new scope parameter in relation attributes that accepts a class implementing a scope interface. This class would allow developers to define complex query conditions that can be reused across different relations.
Example Usage
useCycle\Annotated\Annotation\Relation\HasOne;
useCycle\Annotated\Annotation\Entity;
useApp\Entity\LatestAddressScope;
#[Entity]
class User
{
#[HasOne(target: Address::class, scope: LatestNotEmptyAddressScope::class)]
public ?Address$address;
}
Allows for more flexible and powerful relationship definitions
Improves code reusability by separating query logic into dedicated classes
Enhances readability and maintainability of entity definitions
Provides a consistent way to apply complex conditions across different types of relationships
Supported Relations
This feature would be applicable to the following relation types:
HasOne
HasMany
ManyToMany
Morphed
I believe this feature would greatly enhance the flexibility and power of CycleORM's relationship handling, making it easier for developers to implement complex data models and queries.
The text was updated successfully, but these errors were encountered:
I have an idea!
Add support for scope classes in relation attributes to allow for more complex and reusable query conditions in entity relationships.
Problem
Currently, CycleORM allows defining relationships for an entity using attributes, but there's no built-in way to add additional conditions or complex queries using these attributes. This limitation makes it difficult to handle scenarios where more specific criteria are needed for relationship resolution, such as selecting the latest record or applying custom filtering.
Proposed Solution
Introduce a new
scope
parameter in relation attributes that accepts a class implementing a scope interface. This class would allow developers to define complex query conditions that can be reused across different relations.Example Usage
Scope Class Example
Benefits
Supported Relations
This feature would be applicable to the following relation types:
I believe this feature would greatly enhance the flexibility and power of CycleORM's relationship handling, making it easier for developers to implement complex data models and queries.
The text was updated successfully, but these errors were encountered: