Skip to content

Commit 5e9bed2

Browse files
authored
[6.x] Fix when passed object as parameters to scopes method (#37692)
* Change array cast to Arr::wrap * format
1 parent 5781ad4 commit 5e9bed2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Illuminate/Database/Eloquent/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ public function scopes($scopes)
920920
// messed up when adding scopes. Then we'll return back out the builder.
921921
$builder = $builder->callScope(
922922
[$this->model, 'scope'.ucfirst($scope)],
923-
(array) $parameters
923+
Arr::wrap($parameters)
924924
);
925925
}
926926

tests/Database/DatabaseEloquentModelTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,10 +1873,13 @@ public function testScopesMethod()
18731873
$model = new EloquentModelStub;
18741874
$this->addMockConnection($model);
18751875

1876+
Carbon::setTestNow();
1877+
18761878
$scopes = [
18771879
'published',
18781880
'category' => 'Laravel',
18791881
'framework' => ['Laravel', '5.3'],
1882+
'date' => Carbon::now(),
18801883
];
18811884

18821885
$this->assertInstanceOf(Builder::class, $model->scopes($scopes));
@@ -2112,6 +2115,11 @@ public function scopeFramework(Builder $builder, $framework, $version)
21122115
{
21132116
$this->scopesCalled['framework'] = [$framework, $version];
21142117
}
2118+
2119+
public function scopeDate(Builder $builder, Carbon $date)
2120+
{
2121+
$this->scopesCalled['date'] = $date;
2122+
}
21152123
}
21162124

21172125
trait FooBarTrait

0 commit comments

Comments
 (0)