Skip to content

Commit d363aae

Browse files
committed
[Dev] Added getBaseQuery() method
1 parent 7a5a2e3 commit d363aae

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Contracts/RepositoryInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public function resetScope(): static;
8989

9090
public function applyScope(): static;
9191

92+
public function getBaseQuery(): mixed;
93+
9294
public static function __callStatic($method, $arguments);
9395

9496
public function __call($method, $arguments);

src/Eloquent/BaseRepository.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use CodeOfDigital\CacheRepository\Exceptions\RepositoryException;
1313
use Illuminate\Container\Container as Application;
1414
use Illuminate\Database\Eloquent\Builder;
15+
use Illuminate\Database\Query\Builder as QueryBuilder;
1516
use Illuminate\Database\Eloquent\Model;
1617
use Illuminate\Database\Eloquent\SoftDeletes;
1718
use Illuminate\Support\Collection;
@@ -546,6 +547,17 @@ public function applyScope(): static
546547
});
547548
}
548549

550+
public function getBaseQuery(): QueryBuilder
551+
{
552+
$this->applyCriteria();
553+
$this->applyScope();
554+
555+
$query = $this->model->toBase();
556+
557+
$this->resetModel();
558+
return $query;
559+
}
560+
549561
protected function applyCriteria(): static
550562
{
551563
if ($this->skipCriteria) return $this;

0 commit comments

Comments
 (0)