Skip to content

Commit

Permalink
Merge pull request #124 from alfreddagenais/optimize-currentStatus-query
Browse files Browse the repository at this point in the history
CHG: Optimize `scopeCurrentStatus` and `scopeOtherCurrentStatus` Query
  • Loading branch information
freekmurze authored May 2, 2024
2 parents b29e65d + 6ef92a6 commit c8b8bd3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/HasStatuses.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ function (Builder $query) use ($names) {
->whereIn('name', $names)
->whereIn(
'id',
function (QueryBuilder $query) {
$query
->select(DB::raw('max(id)'))
function (QueryBuilder $subQuery) {
$subQuery
->selectRaw('max(id)')
->from($this->getStatusTableName())
->where('model_type', $this->getStatusModelType())
->whereColumn($this->getModelKeyColumnName(), $this->getQualifiedKeyName());
Expand All @@ -112,9 +112,9 @@ function (Builder $query) use ($names) {
->whereNotIn('name', $names)
->whereIn(
'id',
function (QueryBuilder $query) use ($names) {
$query
->select(DB::raw('max(id)'))
function (QueryBuilder $subQuery) {
$subQuery
->selectRaw('max(id)')
->from($this->getStatusTableName())
->where('model_type', $this->getStatusModelType())
->whereColumn($this->getModelKeyColumnName(), $this->getQualifiedKeyName());
Expand Down

0 comments on commit c8b8bd3

Please sign in to comment.