Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swap to the better Laravel
allRelatedIds
parent logic
This is needed since the previous query used with multisite would return duplicate keys, eg: [1,2,2,2,2,2] since it joined in shared relations (scopes and other constraints were not applied to this query). This would cause integrity violations in the database when saving the duplicates. We looked at adding the following additional constraint: ```php protected function applyMultisiteConstraint() { $model = $this->related; if ( $model && $model->isClassInstanceOf(\October\Contracts\Database\MultisiteInterface::class) && $model->isMultisiteEnabled() && !Site::hasGlobalContext() ) { $this->where($model->getQualifiedSiteIdColumn(), Site::getSiteIdFromContext()); } } ``` However, this is getting too complicated now. The Laravel query just hits the join table and we researched why deferred binding was needed in the first place... - 58f1b1c: Added deferred binding to simple value lookup since it was needed for validation - 1828fbb: Removed the use of simple value in validation for nested attribute validation - b0329f2: Added deferred binding to the validation lookup itself Yet the unused logic still remains. Internally, we can use the much simpler logic found in Laravel instead. Externally, the equivalent functionality is found with a `withDeferred()->pluck('id')->all()` call.
- Loading branch information