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:
@@ -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 @@ class ProductRepository
|
||||
|
||||
/**
|
||||
* Update query builder with resource relationship
|
||||
*
|
||||
* @param mixed $resource
|
||||
*/
|
||||
public function queryAsFromResource($resource): self
|
||||
{
|
||||
@@ -119,7 +125,7 @@ class ProductRepository
|
||||
public function applySearchQueries(): self
|
||||
{
|
||||
if (request()->filled('q')) {
|
||||
$searcQuery = str_replace([
|
||||
$searchQuery = str_replace([
|
||||
'\\',
|
||||
'(',
|
||||
')',
|
||||
@@ -128,7 +134,7 @@ class ProductRepository
|
||||
], '', request('q'));
|
||||
|
||||
// Search by name
|
||||
$this->queryBuilder->where('products.name', '~*', $searcQuery);
|
||||
$this->queryBuilder->where('products.name', '~*', $searchQuery);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -145,7 +151,7 @@ class ProductRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* "Where IN" clouse
|
||||
* "Where IN" clause
|
||||
*/
|
||||
public function whereIn(string $attribute, array $value): self
|
||||
{
|
||||
@@ -155,7 +161,7 @@ class ProductRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* "where integer in raw" clouse
|
||||
* "where integer in raw" clause
|
||||
*/
|
||||
public function whereIntegerInRaw(string $attribute, array $value): self
|
||||
{
|
||||
@@ -180,7 +186,7 @@ class ProductRepository
|
||||
/**
|
||||
* Get the results
|
||||
*/
|
||||
public function get()
|
||||
public function get(): Collection
|
||||
{
|
||||
$this->eagerLoadRelationships();
|
||||
|
||||
@@ -257,6 +263,8 @@ class ProductRepository
|
||||
|
||||
/**
|
||||
* Ajax paginate
|
||||
*
|
||||
* @param mixed $products
|
||||
*/
|
||||
public static function ajaxPaginate($products): JsonResponse
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user