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