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..e62620ab0 --- /dev/null +++ b/database/migrations/Inventory/2024_09_03_104405_add_is_required_to_attributes_table.php @@ -0,0 +1,26 @@ +boolean('is_required')->after('attributes_type_id')->default(false); + $table->index('is_required'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // + } +}; 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") } 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 );