toggle behavior on skus for default product sku, photos for default category photo and default product photo

This commit is contained in:
bs
2025-10-31 01:29:56 -07:00
parent 9f1959a0ee
commit 41c5f7169e
5 changed files with 194 additions and 7 deletions
+16 -1
View File
@@ -58,7 +58,22 @@ class ProductPhotosTable extends Table
);
$this->addBehavior('Timestamp');
$this->addBehavior('Tools.Toggle', [
'field' => 'primary_photo',
'scopeFields' => ['product_id'],
'scope' => [
'deleted IS' => null,
'product_id IS NOT' => null,
],
]);
$this->addBehavior('CakeProducts.SecondToggle', [
'field' => 'primary_category_photo',
'scopeFields' => ['product_category_id'],
'scope' => [
'deleted IS' => null,
'product_category_id IS NOT' => null,
],
]);
$this->belongsTo('Products', [
'foreignKey' => 'product_id',
'joinType' => 'LEFT',
+7
View File
@@ -59,6 +59,13 @@ class ProductSkusTable extends Table
);
$this->addBehavior('Timestamp');
$this->addBehavior('Tools.Toggle', [
'field' => 'default_sku',
'scopeFields' => ['product_id'],
'scope' => [
'deleted IS' => null,
],
]);
$this->belongsTo('Products', [
'className' => 'CakeProducts.Products',