Icinga / ipl-orm

MIT License
1 stars 0 forks source link

Add the possibility to add additional filters for relation #76

Open sukhwinder33445 opened 2 years ago

sukhwinder33445 commented 2 years ago

There should be a method like Relation::additionalFilter() to join table.

Use case

In the partnerportal I join contracts to a customer. It would be nice to have an additional filter to join only non-archived contracts.

Example

Customer::createRelations(Relations $relations)
    {
        $relations
              ->hasMany('contract', Contract::class)
              ->additionalFilter('contract.archived', 0)
              ->setJoinType('LEFT');
    }
nilmerg commented 2 months ago

There are now more cases coming up which require such a functionality. In Icinga DB Web this is generally a problem, because there are multiple tables which have a host_id and a service_id. For services, the host_id is also set and so there's no way to differentiate host and service rows during a join.

Example: https://github.com/Icinga/icingadb-web/pull/1055#pullrequestreview-2312349206