Refactor order creation logic by introducing CreateOrderService and removing the create method from OrderRepository. Update ProductRepository with stricter type declarations and fix minor typos in comments.

This commit is contained in:
nurmuhammet committed 2026-02-05 01:29:10 +05:00
1 parent d0f962220c
commit eaae8b9be9
5 files changed
+160 -54

No files matched your search

@@ -1,11 +1,15 @@
<?php
declare(strict_types=1);
namespace App\Repositories\Ecommerce\Product;
use App\Helpers\Ecommerce\Product\Filter\ProductFilterer;
use App\Helpers\Ecommerce\Product\Sort\ProductSorter;
use App\Models\Ecommerce\Product\Product\Product;
use Illuminate\Contracts\Pagination\Paginator;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -21,7 +25,7 @@ class ProductRepository
*
* @var \Illuminate\Database\Eloquent\Builder
*/
protected mixed $queryBuilder;
protected Builder $queryBuilder;
/**
* Application request
@@ -31,7 +35,7 @@ class ProductRepository
/**
* Relationships to eager load
*
* @var array<int, string>
* @var array<int, string|array>
*/
protected array $with = [];
@@ -54,6 +58,8 @@ public static function make(Request $request): self
/**
* Update query builder with resource relationship
*
* @param mixed $resource
*/
public function queryAsFromResource($resource): self
{
@@ -119,7 +125,7 @@ public function applyFilters(): self
public function applySearchQueries(): self
{
if (request()->filled('q')) {
$searcQuery = str_replace([
$searchQuery = str_replace([
'\\',
'(',
')',
@@ -128,7 +134,7 @@ public function applySearchQueries(): self
], '', request('q'));
// Search by name
$this->queryBuilder->where('products.name', '~*', $searcQuery);
$this->queryBuilder->where('products.name', '~*', $searchQuery);
}
return $this;
@@ -145,7 +151,7 @@ public function applySorting(): self
}
/**
* "Where IN" clouse
* "Where IN" clause
*/
public function whereIn(string $attribute, array $value): self
{
@@ -155,7 +161,7 @@ public function whereIn(string $attribute, array $value): self
}
/**
* "where integer in raw" clouse
* "where integer in raw" clause
*/
public function whereIntegerInRaw(string $attribute, array $value): self
{
@@ -180,7 +186,7 @@ public function simplePaginate(): Paginator
/**
* Get the results
*/
public function get()
public function get(): Collection
{
$this->eagerLoadRelationships();
@@ -257,6 +263,8 @@ public static function sanitizeFileName(string $filename): string
/**
* Ajax paginate
*
* @param mixed $products
*/
public static function ajaxPaginate($products): JsonResponse
{