/** * Remove scope from the query. * * @param \Illuminate\Database\Eloquent\Builder $builder * @param \Illuminate\Database\Eloquent\Model $model * @return void */ public function remove(Builder $builder, Model $model) { $query = $builder->getQuery(); $column = $model->getQualifiedSiteContextColumn(); $bindingKey = 0; foreach ((array) $query->wheres as $key => $where) { if ($this->isSiteContextConstraint($where, $column)) { $this->removeWhere($query, $key); // Here SoftDeletingScope simply removes the where // but since we use Basic where (not Null type) // we need to get rid of the binding as well $this->removeBinding($query, $bindingKey); } // Check if where is either NULL or NOT NULL type, // if that's the case, don't increment the key // since there is no binding for these types if (!in_array($where['type'], ['Null', 'NotNull'])) { $bindingKey++; } } }