nextras / orm

Orm with clean object design, smart relationship loading and powerful collections.
https://nextras.org/orm
MIT License
310 stars 57 forks source link

Traversing through filtered relationships #39

Closed hrach closed 5 years ago

hrach commented 10 years ago

It would be nice to add api & possibility to filter & travers by filtered relationships. Such as

/**
 * @property      Comment[] $allComments {1:m CommentsRepository}
 * @property-read Comment[] $comments {filter $allComments}
 */
class Post extends Entity
{
    public function filterComments(ICollection $collection)
    {
        return $collection->findBy(['deletedAt' => NULL]);
    }
}

// find all posts which were commented by lord Stark
// and these comments weren't deleted.
$this->orm->posts->findBy(['this->comments->author' => $lordStark->id]);
JanTvrdik commented 10 years ago

Damn, I would love to use it right now and v2.0.0 seems so far away.

f3l1x commented 9 years ago

Mmmm, it looks great.

It could be common filter conception - like in LeanMapper.

http://forum.dibiphp.com/cs/14592-lean-mapper-tenke-orm-nad-dibi?p=3#p105447

hrach commented 5 years ago

Filters over relationship in properties were removed (and probably not even released). This concept is currently supported by collection functions.