Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| PurchaseOrderQueryBuilder | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| search | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\PurchaseOrder\QueryBuilders; |
| 4 | |
| 5 | use Domain\PurchaseOrder\DTOs\SearchPurchaseOrderDTO; |
| 6 | use Illuminate\Database\Eloquent\Builder; |
| 7 | |
| 8 | class PurchaseOrderQueryBuilder extends Builder |
| 9 | { |
| 10 | |
| 11 | /** |
| 12 | * @param SearchPurchaseOrderItemDTO $invoiceDTO |
| 13 | * @return $this |
| 14 | */ |
| 15 | public function search(SearchPurchaseOrderDTO $purchaseOrderDTO): static |
| 16 | { |
| 17 | if ($purchaseOrderDTO->id) { |
| 18 | $this->where('id', $purchaseOrderDTO->id); |
| 19 | } |
| 20 | |
| 21 | if ($purchaseOrderDTO->created_at) { |
| 22 | $this->whereBetween('created_at', [ |
| 23 | $purchaseOrderDTO->created_at[0]->startOfDay(), |
| 24 | $purchaseOrderDTO->created_at[1]->endOfDay(), |
| 25 | ]); |
| 26 | } |
| 27 | |
| 28 | if ($purchaseOrderDTO->updated_at) { |
| 29 | $this->whereBetween('updated_at', [ |
| 30 | $purchaseOrderDTO->updated_at[0]->startOfDay(), |
| 31 | $purchaseOrderDTO->updated_at[1]->endOfDay(), |
| 32 | ]); |
| 33 | } |
| 34 | |
| 35 | return $this; |
| 36 | } |
| 37 | } |