Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Is_Required Property to Attributes #1896

Draft
wants to merge 8 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('attributes', function (Blueprint $table) {
$table->boolean('is_required')->after('attributes_type_id')->default(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Keysie27 add it as a index also

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it as a draft and add test for future release

$table->index('is_required');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};
3 changes: 3 additions & 0 deletions graphql/schemas/Inventory/attributes.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ input AttributeInput {
is_visible: Boolean
is_searchable: Boolean
is_filtrable: Boolean
is_required: Boolean
attribute_type: AttributeTypeReferenceInput
}

Expand All @@ -15,6 +16,7 @@ input AttributeUpdateInput {
is_visible: Boolean
is_searchable: Boolean
is_filtrable: Boolean
is_required: Boolean
}

input AttributesValueInput {
Expand All @@ -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")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function __construct(
public bool $isVisible = false,
public bool $isSearchable = false,
public bool $isFiltrable = false,
public bool $isRequired = false,
) {
}

Expand All @@ -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,
);
}
}
3 changes: 2 additions & 1 deletion tests/Connectors/Integration/Shopify/VariantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public function testSetMetafield()
attributeType: null,
isVisible: true,
isSearchable: true,
isFiltrable: true
isFiltrable: true,
isRequired: true
),
$product->user
);
Expand Down
Loading