From faa3f41a28abfb66a1c5c1581e7bac575a6e56a2 Mon Sep 17 00:00:00 2001 From: Keysie27 Date: Tue, 3 Sep 2024 10:15:49 -0400 Subject: [PATCH 1/8] Add is_required property to attributes model --- src/Domains/Inventory/Attributes/Actions/CreateAttribute.php | 1 + src/Domains/Inventory/Attributes/Actions/UpdateAttribute.php | 1 + .../Inventory/Attributes/DataTransferObject/Attributes.php | 2 ++ tests/Connectors/Integration/Shopify/VariantTest.php | 3 ++- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Domains/Inventory/Attributes/Actions/CreateAttribute.php b/src/Domains/Inventory/Attributes/Actions/CreateAttribute.php index 31d4f7ada..f6296110b 100644 --- a/src/Domains/Inventory/Attributes/Actions/CreateAttribute.php +++ b/src/Domains/Inventory/Attributes/Actions/CreateAttribute.php @@ -49,6 +49,7 @@ public function execute(): Attributes 'is_visible' => $this->dto->isVisible, 'is_searchable' => $this->dto->isSearchable, 'is_filtrable' => $this->dto->isFiltrable, + 'is_required' => $this->dto->isRequired, ]); } } diff --git a/src/Domains/Inventory/Attributes/Actions/UpdateAttribute.php b/src/Domains/Inventory/Attributes/Actions/UpdateAttribute.php index b898aea1f..666b8817e 100644 --- a/src/Domains/Inventory/Attributes/Actions/UpdateAttribute.php +++ b/src/Domains/Inventory/Attributes/Actions/UpdateAttribute.php @@ -46,6 +46,7 @@ public function execute(): Attributes 'is_visible' => $this->dto->isVisible, 'is_searchable' => $this->dto->isSearchable, 'is_filtrable' => $this->dto->isFiltrable, + 'is_required' => $this->dto->isRequired, ]); return $this->attribute; diff --git a/src/Domains/Inventory/Attributes/DataTransferObject/Attributes.php b/src/Domains/Inventory/Attributes/DataTransferObject/Attributes.php index 0616a1761..b206bf884 100644 --- a/src/Domains/Inventory/Attributes/DataTransferObject/Attributes.php +++ b/src/Domains/Inventory/Attributes/DataTransferObject/Attributes.php @@ -26,6 +26,7 @@ public function __construct( public bool $isVisible = false, public bool $isSearchable = false, public bool $isFiltrable = false, + public bool $isRequired = false, ) { } @@ -41,6 +42,7 @@ public static function viaRequest(array $request, UserInterface $user): self $request['is_visible'] ?? false, $request['is_searchable'] ?? false, $request['is_filtrable'] ?? false, + $request['is_required'] ?? false, ); } } diff --git a/tests/Connectors/Integration/Shopify/VariantTest.php b/tests/Connectors/Integration/Shopify/VariantTest.php index 09fb69a1c..94efd220e 100644 --- a/tests/Connectors/Integration/Shopify/VariantTest.php +++ b/tests/Connectors/Integration/Shopify/VariantTest.php @@ -78,7 +78,8 @@ public function testSetMetafield() attributeType: null, isVisible: true, isSearchable: true, - isFiltrable: true + isFiltrable: true, + isRequired: true ), $product->user ); From eef34869be059ea44f3d0e56987fbcda5ed4d089 Mon Sep 17 00:00:00 2001 From: Keysie27 Date: Tue, 3 Sep 2024 11:10:05 -0400 Subject: [PATCH 2/8] Migration: Add is_required field in attributes table --- ...05_add_is_required_to_attributes_table.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php diff --git a/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php b/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php new file mode 100644 index 000000000..be61956f7 --- /dev/null +++ b/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php @@ -0,0 +1,25 @@ +boolean('is_required')->after('attributes_type_id')->default(false); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // + } +}; \ No newline at end of file From ab36f3133a574dfe4d0cd4b5c057ff87576471d9 Mon Sep 17 00:00:00 2001 From: Keysie27 Date: Tue, 3 Sep 2024 11:56:25 -0400 Subject: [PATCH 3/8] Add is_required property to schema --- graphql/schemas/Inventory/attributes.graphql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/graphql/schemas/Inventory/attributes.graphql b/graphql/schemas/Inventory/attributes.graphql index 67e846d70..f830d2e03 100644 --- a/graphql/schemas/Inventory/attributes.graphql +++ b/graphql/schemas/Inventory/attributes.graphql @@ -5,6 +5,7 @@ input AttributeInput { is_visible: Boolean is_searchable: Boolean is_filtrable: Boolean + is_required: Boolean attribute_type: AttributeTypeReferenceInput } @@ -15,6 +16,7 @@ input AttributeUpdateInput { is_visible: Boolean is_searchable: Boolean is_filtrable: Boolean + is_required: Boolean } input AttributesValueInput { @@ -32,6 +34,7 @@ type Attributes { is_visible: Boolean is_searchable: Boolean is_filtrable: Boolean + is_required: Boolean values: [AttributesValue!] @hasMany(relation: "defaultValues") attribute_type: AttributesType @belongsTo(relation: "attributeType") } From e360893db553c90134994403bff3f6775dfd221b Mon Sep 17 00:00:00 2001 From: Keysie27 Date: Tue, 3 Sep 2024 12:03:22 -0400 Subject: [PATCH 4/8] Stylo --- .../2024_09_03_104405_add_is_required_to_attributes_table.php | 1 + 1 file changed, 1 insertion(+) diff --git a/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php b/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php index be61956f7..0910d3940 100644 --- a/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php +++ b/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php @@ -22,4 +22,5 @@ public function down(): void { // } + }; \ No newline at end of file From 3bcc37e336794165426bb4c3a7c0d03dd61927d3 Mon Sep 17 00:00:00 2001 From: Keysie27 Date: Tue, 3 Sep 2024 12:05:57 -0400 Subject: [PATCH 5/8] Stylo --- .../2024_09_03_104405_add_is_required_to_attributes_table.php | 1 - 1 file changed, 1 deletion(-) diff --git a/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php b/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php index 0910d3940..be61956f7 100644 --- a/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php +++ b/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php @@ -22,5 +22,4 @@ public function down(): void { // } - }; \ No newline at end of file From aba44d66d0f22018f40208b0845db3650f49b5fb Mon Sep 17 00:00:00 2001 From: arfenis Date: Tue, 3 Sep 2024 12:19:58 -0400 Subject: [PATCH 6/8] stylo99 --- .../2024_09_03_104405_add_is_required_to_attributes_table.php | 1 + 1 file changed, 1 insertion(+) diff --git a/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php b/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php index be61956f7..0910d3940 100644 --- a/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php +++ b/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php @@ -22,4 +22,5 @@ public function down(): void { // } + }; \ No newline at end of file From 8d4c62a9a146a05bceda7ce866c8c5fe1028efec Mon Sep 17 00:00:00 2001 From: arfenis Date: Tue, 3 Sep 2024 12:22:03 -0400 Subject: [PATCH 7/8] stylo3 --- .../2024_09_03_104405_add_is_required_to_attributes_table.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php b/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php index 0910d3940..3176551d3 100644 --- a/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php +++ b/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php @@ -22,5 +22,4 @@ public function down(): void { // } - -}; \ No newline at end of file +}; From 24a081e3add622f1f8632d00a8cb29f856473af7 Mon Sep 17 00:00:00 2001 From: Keysie27 Date: Tue, 3 Sep 2024 12:38:27 -0400 Subject: [PATCH 8/8] add is_required as a index to attributes table --- .../2024_09_03_104405_add_is_required_to_attributes_table.php | 1 + 1 file changed, 1 insertion(+) diff --git a/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php b/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php index 3176551d3..e62620ab0 100644 --- a/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php +++ b/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php @@ -12,6 +12,7 @@ public function up(): void { Schema::table('attributes', function (Blueprint $table) { $table->boolean('is_required')->after('attributes_type_id')->default(false); + $table->index('is_required'); }); }