diff --git a/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php b/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php index fe90c84c1d5..0d424995cff 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php +++ b/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php @@ -536,7 +536,7 @@ public function orWhereMorphDoesntHaveRelation($relation, $types, $column, $oper * Add a morph-to relationship condition to the query. * * @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation - * @param \Illuminate\Database\Eloquent\Model|\Illuminate\Support\Collection|string|null $model + * @param \Illuminate\Database\Eloquent\Model|Iterable|string|null $model * @return $this */ public function whereMorphedTo($relation, $model, $boolean = 'and') @@ -579,7 +579,7 @@ public function whereMorphedTo($relation, $model, $boolean = 'and') * Add a not morph-to relationship condition to the query. * * @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation - * @param \Illuminate\Database\Eloquent\Model|\Illuminate\Support\Collection|string $model + * @param \Illuminate\Database\Eloquent\Model|Iterable|string $model * @return $this */ public function whereNotMorphedTo($relation, $model, $boolean = 'and') @@ -618,7 +618,7 @@ public function whereNotMorphedTo($relation, $model, $boolean = 'and') * Add a morph-to relationship condition to the query with an "or where" clause. * * @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation - * @param \Illuminate\Database\Eloquent\Model|\Illuminate\Support\Collection|string|null $model + * @param \Illuminate\Database\Eloquent\Model|Iterable|string|null $model * @return $this */ public function orWhereMorphedTo($relation, $model) @@ -630,7 +630,7 @@ public function orWhereMorphedTo($relation, $model) * Add a not morph-to relationship condition to the query with an "or where" clause. * * @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation - * @param \Illuminate\Database\Eloquent\Model|\Illuminate\Support\Collection|string $model + * @param \Illuminate\Database\Eloquent\Model|Iterable|string $model * @return $this */ public function orWhereNotMorphedTo($relation, $model) diff --git a/tests/Database/DatabaseEloquentBuilderTest.php b/tests/Database/DatabaseEloquentBuilderTest.php index 85cda40ef9f..a84cd851eb0 100755 --- a/tests/Database/DatabaseEloquentBuilderTest.php +++ b/tests/Database/DatabaseEloquentBuilderTest.php @@ -1809,7 +1809,7 @@ public function testWhereMorphedToCollectionWithDifferentModels() $thirdRelatedModel = new EloquentBuilderTestModelCloseRelatedStub; $thirdRelatedModel->id = 3; - $builder = $model->whereMorphedTo('morph', new Collection([$firstRelatedModel, $secondRelatedModel, $thirdRelatedModel])); + $builder = $model->whereMorphedTo('morph', [$firstRelatedModel, $secondRelatedModel, $thirdRelatedModel]); $this->assertSame('select * from "eloquent_builder_test_model_parent_stubs" where (("eloquent_builder_test_model_parent_stubs"."morph_type" = ? and "eloquent_builder_test_model_parent_stubs"."morph_id" in (?, ?)) or ("eloquent_builder_test_model_parent_stubs"."morph_type" = ? and "eloquent_builder_test_model_parent_stubs"."morph_id" in (?)))', $builder->toSql()); $this->assertEquals([$firstRelatedModel->getMorphClass(), $firstRelatedModel->getKey(), $thirdRelatedModel->getKey(), $secondRelatedModel->getMorphClass(), $secondRelatedModel->id], $builder->getBindings()); @@ -1869,7 +1869,7 @@ public function testWhereNotMorphedToCollectionWithDifferentModels() $thirdRelatedModel = new EloquentBuilderTestModelCloseRelatedStub; $thirdRelatedModel->id = 3; - $builder = $model->whereNotMorphedTo('morph', new Collection([$firstRelatedModel, $secondRelatedModel, $thirdRelatedModel])); + $builder = $model->whereNotMorphedTo('morph', [$firstRelatedModel, $secondRelatedModel, $thirdRelatedModel]); $this->assertSame('select * from "eloquent_builder_test_model_parent_stubs" where not (("eloquent_builder_test_model_parent_stubs"."morph_type" <=> ? and "eloquent_builder_test_model_parent_stubs"."morph_id" not in (?, ?)) or ("eloquent_builder_test_model_parent_stubs"."morph_type" <=> ? and "eloquent_builder_test_model_parent_stubs"."morph_id" not in (?)))', $builder->toSql()); $this->assertEquals([$firstRelatedModel->getMorphClass(), $firstRelatedModel->getKey(), $thirdRelatedModel->getKey(), $secondRelatedModel->getMorphClass(), $secondRelatedModel->id], $builder->getBindings()); @@ -1920,7 +1920,7 @@ public function testOrWhereMorphedToCollectionWithDifferentModels() $thirdRelatedModel = new EloquentBuilderTestModelCloseRelatedStub; $thirdRelatedModel->id = 3; - $builder = $model->where('bar', 'baz')->orWhereMorphedTo('morph', new Collection([$firstRelatedModel, $secondRelatedModel, $thirdRelatedModel])); + $builder = $model->where('bar', 'baz')->orWhereMorphedTo('morph', [$firstRelatedModel, $secondRelatedModel, $thirdRelatedModel]); $this->assertSame('select * from "eloquent_builder_test_model_parent_stubs" where "bar" = ? or (("eloquent_builder_test_model_parent_stubs"."morph_type" = ? and "eloquent_builder_test_model_parent_stubs"."morph_id" in (?, ?)) or ("eloquent_builder_test_model_parent_stubs"."morph_type" = ? and "eloquent_builder_test_model_parent_stubs"."morph_id" in (?)))', $builder->toSql()); $this->assertEquals(['baz', $firstRelatedModel->getMorphClass(), $firstRelatedModel->getKey(), $thirdRelatedModel->getKey(), $secondRelatedModel->getMorphClass(), $secondRelatedModel->id], $builder->getBindings()); @@ -1982,7 +1982,7 @@ public function testOrWhereNotMorphedToCollectionWithDifferentModels() $thirdRelatedModel = new EloquentBuilderTestModelCloseRelatedStub; $thirdRelatedModel->id = 3; - $builder = $model->where('bar', 'baz')->orWhereNotMorphedTo('morph', new Collection([$firstRelatedModel, $secondRelatedModel, $thirdRelatedModel])); + $builder = $model->where('bar', 'baz')->orWhereNotMorphedTo('morph', [$firstRelatedModel, $secondRelatedModel, $thirdRelatedModel]); $this->assertSame('select * from "eloquent_builder_test_model_parent_stubs" where "bar" = ? or not (("eloquent_builder_test_model_parent_stubs"."morph_type" <=> ? and "eloquent_builder_test_model_parent_stubs"."morph_id" not in (?, ?)) or ("eloquent_builder_test_model_parent_stubs"."morph_type" <=> ? and "eloquent_builder_test_model_parent_stubs"."morph_id" not in (?)))', $builder->toSql()); $this->assertEquals(['baz', $firstRelatedModel->getMorphClass(), $firstRelatedModel->getKey(), $thirdRelatedModel->getKey(), $secondRelatedModel->getMorphClass(), $secondRelatedModel->id], $builder->getBindings());