Skip to content

Commit

Permalink
Merge branch 'origin/develop' into feature/HES-2289
Browse files Browse the repository at this point in the history
  • Loading branch information
Witold Wiśniewski committed Sep 21, 2023
2 parents 9441aaa + 29f7be8 commit 9b066f6
Show file tree
Hide file tree
Showing 202 changed files with 1,699 additions and 4,678 deletions.
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ REDIS_CACHE_HOST=redis
REDIS_CACHE_PASSWORD=null
REDIS_CACHE_PORT=6379

SCOUT_DRIVER=database
SCOUT_QUEUE=false

EMAIL_HOST=mail.example.com
EMAIL_PORT=587
EMAIL_ENCRYPTION=tls
Expand Down
2 changes: 1 addition & 1 deletion app/Casts/MetadataValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function get($model, string $key, $value, array $attributes): mixed
return match ($model->value_type->value) {
MetadataType::BOOLEAN => (bool) $value,
MetadataType::NUMBER => (float) $value,
default => $value
default => $value,
};
}

Expand Down
1 change: 0 additions & 1 deletion app/Console/Commands/RefreshProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public function handle(): int

$productService = app(ProductServiceContract::class);
$productService->updateMinMaxPrices($product);
$product->searchable();

$this->info('Done.');

Expand Down
11 changes: 7 additions & 4 deletions app/Criteria/MediaSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ class MediaSearch extends Criterion
public function query(Builder $query): Builder
{
if ($this->value) {
$query->where('url', 'like', "%{$this->value}%")
->orWhere('slug', 'like', "%{$this->value}%")
->orWhere('alt', 'like', "%{$this->value}%")
->orWhere('type', 'like', "%{$this->value}%");
$query->where(function (Builder $query): void {
$query
->where('url', 'like', "%{$this->value}%")
->orWhere('slug', 'like', "%{$this->value}%")
->orWhere('alt', 'like', "%{$this->value}%")
->orWhere('type', 'like', "%{$this->value}%");
});
}

return $query;
Expand Down
4 changes: 2 additions & 2 deletions app/Criteria/ProductAttributeSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public function query(Builder $query): Builder
$query
->from('product_attribute_attribute_option')
->whereRaw(
'`product_attribute`.`id` = `product_attribute_attribute_option`.`product_attribute_id`'
'`product_attribute`.`id` = `product_attribute_attribute_option`.`product_attribute_id`',
);

if (is_array($value)) {
$query->join(
'attribute_options',
'product_attribute_attribute_option.attribute_option_id',
'=',
'attribute_options.id'
'attribute_options.id',
);

$key = is_numeric(Arr::first($value)) ?
Expand Down
4 changes: 2 additions & 2 deletions app/Criteria/ProductNotAttributeSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public function query(Builder $query): Builder
$query
->from('product_attribute_attribute_option')
->whereRaw(
'`product_attribute`.`id` = `product_attribute_attribute_option`.`product_attribute_id`'
'`product_attribute`.`id` = `product_attribute_attribute_option`.`product_attribute_id`',
);

if (is_array($value)) {
$query->join(
'attribute_options',
'product_attribute_attribute_option.attribute_option_id',
'=',
'attribute_options.id'
'attribute_options.id',
);

$key = is_numeric(Arr::first($value)) ?
Expand Down
17 changes: 7 additions & 10 deletions app/Criteria/ProductSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ class ProductSearch extends Criterion
{
public function query(Builder $query): Builder
{
if ($this->value === null) {
return $query;
}

return $query->where(function (Builder $query): void {
$query->where('id', 'LIKE', '%' . $this->value . '%')
->orWhere('slug', 'LIKE', '%' . $this->value . '%')
->orWhere('name', 'LIKE', '%' . $this->value . '%')
->orWhere('description_html', 'LIKE', '%' . $this->value . '%');
});
return $query->whereFullText([
'name',
'slug',
'description_html',
'description_short',
'search_values',
], $this->value);
}
}
4 changes: 2 additions & 2 deletions app/Criteria/WhereHasBuyer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public function query(Builder $query): Builder
fn (Builder $query) => $query
->whereDoesntHave(
'status',
fn (Builder $query) => $query->where('cancel', '!=', false)
fn (Builder $query) => $query->where('cancel', '!=', false),
)
->whereHasMorph(
'buyer',
$this->key === 'user' ? [User::class] : [App::class],
fn (Builder $query) => $query->where('id', $this->value),
)
),
);
}
}
2 changes: 1 addition & 1 deletion app/Dtos/AttributeDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
) {}

public static function instantiateFromRequest(
AttributeStoreRequest|AttributeUpdateRequest|FormRequest $request
AttributeStoreRequest|AttributeUpdateRequest|FormRequest $request,
): self {
return new self(
id: $request->input('id', new Missing()),
Expand Down
2 changes: 1 addition & 1 deletion app/Dtos/BannerMediaDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function fromDataArray(array $data): self
title: $data['title'] ?? null,
subtitle: $data['subtitle'] ?? null,
media: Collection::make($responsiveMedia)
->map(fn ($media) => ResponsiveMediaDto::fromDataArray($media))
->map(fn ($media) => ResponsiveMediaDto::fromDataArray($media)),
);
}

Expand Down
4 changes: 2 additions & 2 deletions app/Dtos/ConditionGroupDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ConditionGroupDto extends Dto
public static function fromArray(array $array): self
{
return new self(
conditions: self::transformArrayToConditionDtos($array)
conditions: self::transformArrayToConditionDtos($array),
);
}

Expand All @@ -39,7 +39,7 @@ private static function transformArrayToConditionDtos(array $conditions): array
ConditionType::WEEKDAY_IN => WeekDayInConditionDto::fromArray($condition),
ConditionType::CART_LENGTH => CartLengthConditionDto::fromArray($condition),
ConditionType::COUPONS_COUNT => CouponsCountConditionDto::fromArray($condition),
default => throw new Exception('Unknown condition type.')
default => throw new Exception('Unknown condition type.'),
};
}

Expand Down
2 changes: 1 addition & 1 deletion app/Dtos/CouponDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class CouponDto extends SaleDto implements InstantiateFromRequest
protected array|Missing $metadata;

public static function instantiateFromRequest(
CouponCreateRequest|CouponUpdateRequest|FormRequest|SaleCreateRequest|StatusUpdateRequest $request
CouponCreateRequest|CouponUpdateRequest|FormRequest|SaleCreateRequest|StatusUpdateRequest $request,
): self {
return new self(
code: $request->input('code', new Missing()),
Expand Down
2 changes: 1 addition & 1 deletion app/Dtos/MediaAttachmentDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function instantiateFromRequest(FormRequest $request): self
name: $request->input('name'),
type: $type,
visibility: $visibility,
description: $request->input('description') ?? new Missing()
description: $request->input('description') ?? new Missing(),
);
}
}
21 changes: 3 additions & 18 deletions app/Dtos/ProductSearchDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class ProductSearchDto extends Dto implements InstantiateFromRequest
{
private ?string $search;
private Missing|string $search;
private ?string $sort;

private array|Missing $ids;
Expand Down Expand Up @@ -46,7 +46,7 @@ public static function instantiateFromRequest(FormRequest|ProductIndexRequest $r
? Str::replace('price:desc', 'price_max:desc', $sort) : $sort;

return new self(
search: $request->input('search'),
search: $request->input('search', new Missing()),
sort: $sort,
ids: $request->input('ids', new Missing()),
slug: $request->input('slug', new Missing()),
Expand All @@ -66,30 +66,15 @@ public static function instantiateFromRequest(FormRequest|ProductIndexRequest $r
metadata: self::array('metadata', $request),
metadata_private: self::array('metadata_private', $request),
price_min: $request->input('price.min', new Missing()),
price_max: $request->input('price.max', new Missing())
price_max: $request->input('price.max', new Missing()),
);
}

public function getSearch(): ?string
{
return $this->search;
}

public function getSort(): ?string
{
return $this->sort;
}

public function getPriceMin(): float|Missing
{
return $this->price_min;
}

public function getPriceMax(): float|Missing
{
return $this->price_max;
}

private static function boolean(string $key, FormRequest|ProductIndexRequest $request): bool|Missing
{
if (!$request->has($key)) {
Expand Down
2 changes: 1 addition & 1 deletion app/Dtos/ProductSetDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(
* @throws DtoException
*/
public static function instantiateFromRequest(
FormRequest|ProductSetStoreRequest|ProductSetUpdateRequest $request
FormRequest|ProductSetStoreRequest|ProductSetUpdateRequest $request,
): self {
return new self(
id: $request->input('id') ?? new Missing(),
Expand Down
2 changes: 1 addition & 1 deletion app/Dtos/ProductSetUpdateDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ProductSetUpdateDto extends Dto implements InstantiateFromRequest
private array|Missing|null $attributes_ids;

public static function instantiateFromRequest(
FormRequest|ProductSetStoreRequest|ProductSetUpdateRequest $request
FormRequest|ProductSetStoreRequest|ProductSetUpdateRequest $request,
): self {
return new self(
name: $request->input('name', new Missing()),
Expand Down
2 changes: 1 addition & 1 deletion app/Dtos/ProductsReorderDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class ProductsReorderDto extends Dto
protected array|Missing $products;

public static function instantiateFromRequest(
FormRequest|ProductSetProductReorderRequest $request
FormRequest|ProductSetProductReorderRequest $request,
): self {
return new self(
products: $request->input('products', new Missing()),
Expand Down
2 changes: 1 addition & 1 deletion app/Dtos/UserPreferencesDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static function instantiateFromRequest(Request $request): self
new_localization_login_alert: $request
->input('preferences.new_localization_login_alert', new Missing()),
recovery_code_changed_alert: $request
->input('preferences.recovery_code_changed_alert', new Missing())
->input('preferences.recovery_code_changed_alert', new Missing()),
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Enums/ExceptionsEnums/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static function getCode(string $value): int
self::SERVER_ERROR,
self::SERVER_ORDER_STATUSES_NOT_CONFIGURED,
self::SERVER_PAYMENT_MICROSERVICE_ERROR => 500,
default => 422
default => 422,
};
}
}
10 changes: 5 additions & 5 deletions app/Events/ProductPriceUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class ProductPriceUpdated extends WebHookEvent
private string $updatedAt;

public function __construct(
private string $id,
private ?float $oldPriceMin,
private ?float $oldPriceMax,
private float $newPriceMin,
private float $newPriceMax,
private readonly string $id,
private readonly ?float $oldPriceMin,
private readonly ?float $oldPriceMax,
private readonly float $newPriceMin,
private readonly float $newPriceMax,
) {
$this->updatedAt = Carbon::now()->toIso8601String();
parent::__construct();
Expand Down
16 changes: 16 additions & 0 deletions app/Events/ProductSearchValueEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Events;

use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class ProductSearchValueEvent
{
use Dispatchable;
use SerializesModels;

public function __construct(
public readonly array $product_ids,
) {}
}
2 changes: 1 addition & 1 deletion app/Exceptions/AuthException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function __construct(
string $message = '',
int $code = 0,
?Throwable $previous = null,
bool $simpleLogs = false
bool $simpleLogs = false,
) {
parent::__construct($message, $code, $previous, $simpleLogs);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/DiscountException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class DiscountException extends StoreException
public function __construct(
string $message = '',
int $code = 0,
?Throwable $previous = null
?Throwable $previous = null,
) {
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct(
public int $code = 500,
public string $key = 'INTERNAL_SERVER_ERROR',
public array $errors = [],
public array $stack = []
public array $stack = [],
) {}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private function createValidationAttributeData(string $key, array $data): array
ValidationError::GTE => [
'field' => $data[0],
],
default => []
default => [],
};
}
}
2 changes: 1 addition & 1 deletion app/Exceptions/ItemException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ItemException extends StoreException
public function __construct(
string $message = '',
int $code = 0,
?Throwable $previous = null
?Throwable $previous = null,
) {
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/MediaCriticalException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MediaCriticalException extends StoreException
public function __construct(
string $message = '',
int $code = 0,
?Throwable $previous = null
?Throwable $previous = null,
) {
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/MediaException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MediaException extends StoreException
public function __construct(
string $message = '',
int $code = 0,
?Throwable $previous = null
?Throwable $previous = null,
) {
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/OrderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class OrderException extends StoreException
public function __construct(
string $message = '',
int $code = 0,
?Throwable $previous = null
?Throwable $previous = null,
) {
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/PackageAuthException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class PackageAuthException extends StoreException
public function __construct(
string $message = '',
int $code = 0,
?Throwable $previous = null
?Throwable $previous = null,
) {
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/RoleException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RoleException extends StoreException
public function __construct(
string $message = '',
int $code = 0,
?Throwable $previous = null
?Throwable $previous = null,
) {
parent::__construct($message, $code, $previous);
}
Expand Down
Loading

0 comments on commit 9b066f6

Please sign in to comment.