product id back on product category variants table...dumb
This commit is contained in:
@@ -12,6 +12,7 @@ use Cake\ORM\Entity;
|
||||
* @property string $id
|
||||
* @property string $name
|
||||
* @property string|null $product_category_id
|
||||
* @property string|null $product_id
|
||||
* @property bool $enabled
|
||||
*
|
||||
* @property ProductCategory|EntityInterface $product_category
|
||||
@@ -31,10 +32,12 @@ class ProductCategoryVariant extends Entity
|
||||
protected array $_accessible = [
|
||||
'name' => true,
|
||||
'product_category_id' => true,
|
||||
'product_id' => true,
|
||||
'enabled' => true,
|
||||
|
||||
// entities
|
||||
'product_category' => false,
|
||||
'product' => false,
|
||||
'product_category_variant_options' => true,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -61,6 +61,10 @@ class ProductCategoryVariantsTable extends Table
|
||||
'bindingKey' => 'internal_id',
|
||||
'className' => 'CakeProducts.ProductCategories',
|
||||
]);
|
||||
$this->belongsTo('Products', [
|
||||
'foreignKey' => 'product_id',
|
||||
'className' => 'CakeProducts.Products',
|
||||
]);
|
||||
$this->hasMany('ProductCategoryVariantOptions', [
|
||||
'foreignKey' => 'product_category_variant_id',
|
||||
'className' => 'CakeProducts.ProductCategoryVariantOptions',
|
||||
@@ -109,7 +113,9 @@ class ProductCategoryVariantsTable extends Table
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
$rules->add($rules->isUnique(['name', 'product_category_id'], ['allowMultipleNulls' => true]), ['errorField' => 'product_category_id']);
|
||||
$rules->add($rules->isUnique(['name', 'product_id'], ['allowMultipleNulls' => true]), ['errorField' => 'product_id']);
|
||||
$rules->add($rules->existsIn(['product_category_id'], 'ProductCategories'), ['errorField' => 'product_category_id']);
|
||||
$rules->add($rules->existsIn(['product_id'], 'Products'), ['errorField' => 'product_id']);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user