Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Fix when passed object as parameters to scopes method #37692

Merged
merged 2 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ public function scopes($scopes)
// messed up when adding scopes. Then we'll return back out the builder.
$builder = $builder->callScope(
[$this->model, 'scope'.ucfirst($scope)],
(array) $parameters
Arr::wrap($parameters)
);
}

Expand Down
8 changes: 8 additions & 0 deletions tests/Database/DatabaseEloquentModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1873,10 +1873,13 @@ public function testScopesMethod()
$model = new EloquentModelStub;
$this->addMockConnection($model);

Carbon::setTestNow();

$scopes = [
'published',
'category' => 'Laravel',
'framework' => ['Laravel', '5.3'],
'date' => Carbon::now(),
];

$this->assertInstanceOf(Builder::class, $model->scopes($scopes));
Expand Down Expand Up @@ -2112,6 +2115,11 @@ public function scopeFramework(Builder $builder, $framework, $version)
{
$this->scopesCalled['framework'] = [$framework, $version];
}

public function scopeDate(Builder $builder, Carbon $date)
{
$this->scopesCalled['date'] = $date;
}
}

trait FooBarTrait
Expand Down