unique rules, allow product id to be null in product photos
This commit is contained in:
@@ -10,7 +10,7 @@ use Cake\ORM\Entity;
|
||||
* ProductPhoto Entity
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $product_id
|
||||
* @property string|null $product_id
|
||||
* @property string|null $product_category_id
|
||||
* @property string|null $product_sku_id
|
||||
* @property string $photo_dir
|
||||
@@ -55,6 +55,8 @@ class ProductPhoto extends Entity
|
||||
'deleted' => true,
|
||||
|
||||
// entities
|
||||
'product' => true,
|
||||
'product' => false,
|
||||
'product_sku' => false,
|
||||
'product_category' => false,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ class ProductCategoryAttributeOptionsTable extends Table
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
$rules->add($rules->existsIn(['product_category_attribute_id'], 'ProductCategoryAttributes'), ['errorField' => 'product_category_attribute_id']);
|
||||
$rules->add($rules->isUnique(['attribute_value', 'product_category_attribute_id']));
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
@@ -105,6 +105,7 @@ class ProductCategoryVariantOptionsTable extends Table
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
$rules->add($rules->existsIn(['product_category_variant_id'], 'ProductCategoryVariants'), ['errorField' => 'product_category_variant_id']);
|
||||
$rules->add($rules->isUnique(['variant_value', 'product_category_variant_id']));
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user