diff --git a/app/Http/Requests/ProductCreateRequest.php b/app/Http/Requests/ProductCreateRequest.php index 55fbd58f..de282b54 100644 --- a/app/Http/Requests/ProductCreateRequest.php +++ b/app/Http/Requests/ProductCreateRequest.php @@ -29,11 +29,12 @@ public function rules(): array 'id' => ['uuid'], 'translations' => [ 'required', - new Translations(['name', 'description_html', 'description_short']), + new Translations(['name', 'description_html', 'description_short', 'safety_information']), ], 'translations.*.name' => ['required', 'string', 'max:255'], 'translations.*.description_html' => ['nullable', 'string'], 'translations.*.description_short' => ['nullable', 'string'], + 'translations.*.safety_information' => ['nullable', 'string'], 'published' => ['required', 'array', 'min:1'], 'published.*' => ['uuid', 'exists:languages,id'], diff --git a/app/Http/Requests/ProductUpdateRequest.php b/app/Http/Requests/ProductUpdateRequest.php index 2cd4324d..7fa7f2b7 100644 --- a/app/Http/Requests/ProductUpdateRequest.php +++ b/app/Http/Requests/ProductUpdateRequest.php @@ -33,7 +33,7 @@ public function rules(): array $rules['published'] = ['nullable', 'array', 'min:1']; $rules['translations'] = [ 'nullable', - new Translations(['name', 'description_html', 'description_short']), + new Translations(['name', 'description_html', 'description_short', 'safety_information']), ]; $rules['banner'] = ['nullable', 'array']; diff --git a/docs/api.yml b/docs/api.yml index 3124d537..4311b2df 100644 --- a/docs/api.yml +++ b/docs/api.yml @@ -342,6 +342,10 @@ paths: $ref: './paths/Redirects.yml#/RedirectsParams' /email: $ref: './paths/Emails.yml#/Emails' + /manufacturers: + $ref: './paths/Manufacturers.yml#/Manufacturers' + /manufacturers/id:{id}: + $ref: './paths/Manufacturers.yml#/ManufacturersParams' components: schemas: Error: diff --git a/src/Domain/Manufacturer/Criteria/ManufacturerSearch.php b/src/Domain/Manufacturer/Criteria/ManufacturerSearch.php index 6d39ea98..eb08959e 100644 --- a/src/Domain/Manufacturer/Criteria/ManufacturerSearch.php +++ b/src/Domain/Manufacturer/Criteria/ManufacturerSearch.php @@ -19,19 +19,25 @@ public function query(Builder $query): Builder { return $query->where( fn (Builder $query) => $query - ->where('name', 'LIKE', '%' . $this->value . '%') - ->orWhere('first_name', 'LIKE', '%' . $this->value . '%') - ->orWhere('last_name', 'LIKE', '%' . $this->value . '%') + // @phpstan-ignore-next-line + ->where(fn (Builder $query) => $query + ->where('name', 'LIKE', '%' . $this->value . '%') + ->orWhere('first_name', 'LIKE', '%' . $this->value . '%') + ->orWhere('last_name', 'LIKE', '%' . $this->value . '%') + ->orWhereRaw("CONCAT(first_name, ' ', last_name) LIKE ?", ['%' . $this->value . '%']), + ) ->orWhereHas( 'address', fn (Builder $query) => $query - ->orWhere('name', 'LIKE', '%' . $this->value . '%') - ->orWhere('phone', 'LIKE', '%' . $this->value . '%') - ->orWhere('address', 'LIKE', '%' . $this->value . '%') - ->orWhere('vat', 'LIKE', '%' . $this->value . '%') - ->orWhere('zip', 'LIKE', '%' . $this->value . '%') - ->orWhere('city', 'LIKE', '%' . $this->value . '%') - ->orWhere('country', 'LIKE', '%' . $this->value . '%'), + ->where(fn (Builder $query) => $query + ->orWhere('addresses.name', 'LIKE', '%' . $this->value . '%') + ->orWhere('addresses.phone', 'LIKE', '%' . $this->value . '%') + ->orWhere('addresses.address', 'LIKE', '%' . $this->value . '%') + ->orWhere('addresses.vat', 'LIKE', '%' . $this->value . '%') + ->orWhere('addresses.zip', 'LIKE', '%' . $this->value . '%') + ->orWhere('addresses.city', 'LIKE', '%' . $this->value . '%') + ->orWhere('addresses.country', 'LIKE', '%' . $this->value . '%'), + ), ), ); } diff --git a/src/Domain/Product/Dtos/ProductCreateDto.php b/src/Domain/Product/Dtos/ProductCreateDto.php index 14ac0b1d..3549c09a 100644 --- a/src/Domain/Product/Dtos/ProductCreateDto.php +++ b/src/Domain/Product/Dtos/ProductCreateDto.php @@ -72,7 +72,6 @@ public function __construct( public array $published, public Optional|ProductBannerMediaCreateDto|null $banner, public Optional|string|null $manufacturer_id, - public Optional|string|null $safety_information, ) { $this->metadata_computed = Map::toMetadata($metadata_public, $metadata_private); } diff --git a/src/Domain/Product/Dtos/ProductUpdateDto.php b/src/Domain/Product/Dtos/ProductUpdateDto.php index fd11d749..e9986ed1 100644 --- a/src/Domain/Product/Dtos/ProductUpdateDto.php +++ b/src/Domain/Product/Dtos/ProductUpdateDto.php @@ -61,7 +61,6 @@ public function __construct( public array|Optional $published, public Optional|ProductBannerMediaUpdateDto|null $banner, public Optional|string|null $manufacturer_id, - public Optional|string|null $safety_information, ) { $this->metadata_computed = new Optional(); } diff --git a/tests/Feature/Products/ProductCreateTest.php b/tests/Feature/Products/ProductCreateTest.php index ffc4843b..1b59fdc3 100644 --- a/tests/Feature/Products/ProductCreateTest.php +++ b/tests/Feature/Products/ProductCreateTest.php @@ -295,6 +295,7 @@ public function testCreateWithManufacturer(string $user): void 'translations' => [ $this->lang => [ 'name' => 'Test', + 'safety_information' => 'Safety', ], ], 'published' => [$this->lang], @@ -303,7 +304,6 @@ public function testCreateWithManufacturer(string $user): void 'public' => true, 'shipping_digital' => false, 'manufacturer_id' => $manufacturer->getKey(), - 'safety_information' => 'Safety', ]) ->assertCreated() ->assertJsonFragment([ @@ -666,7 +666,12 @@ public function testUpdateManufacturer(string $user): void ->actingAs($this->{$user}) ->json('PATCH', "/products/id:{$product->getKey()}", [ 'manufacturer_id' => $manufacturer->getKey(), - 'safety_information' => 'Safety', + 'translations' => [ + $this->lang => [ + 'name' => $product->name, + 'safety_information' => 'Safety', + ] + ], ]) ->assertOk() ->assertJsonFragment([