belongs to many external catalogs & catalogs

This commit is contained in:
2025-03-30 22:43:04 -07:00
parent 3a98baae7c
commit b627550dd9
7 changed files with 67 additions and 17 deletions

View File

@@ -54,9 +54,8 @@ class ExternalProductCatalogsTable extends Table
$this->addBehavior('Timestamp');
$this->belongsTo('ProductCatalogs', [
'foreignKey' => 'product_catalog_id',
'joinType' => 'INNER',
$this->belongsToMany('ProductCatalogs', [
'through' => 'CakeProducts.ExternalProductCatalogsProductCatalogs',
'className' => 'CakeProducts.ProductCatalogs',
]);
}
@@ -91,11 +90,6 @@ class ExternalProductCatalogsTable extends Table
->dateTime('deleted')
->allowEmptyDateTime('deleted');
$validator
->boolean('enabled')
->requirePresence('enabled', 'create')
->notEmptyString('enabled');
return $validator;
}

View File

@@ -53,7 +53,8 @@ class ProductCatalogsTable extends Table
$this->hasMany('ProductCategories', [
'className' => 'CakeProducts.ProductCategories',
]);
$this->hasMany('ExternalProductCatalogs', [
$this->belongsToMany('ExternalProductCatalogs', [
'through' => 'CakeProducts.ExternalProductCatalogsProductCatalogs',
'className' => 'CakeProducts.ExternalProductCatalogs',
]);
}