diff --git a/src/Model/Table/ProductsTable.php b/src/Model/Table/ProductsTable.php index 38d53f9..44077b9 100644 --- a/src/Model/Table/ProductsTable.php +++ b/src/Model/Table/ProductsTable.php @@ -83,6 +83,20 @@ class ProductsTable extends Table 'cascadeCallbacks' => true, ]); + $this->hasMany('ProductPhotos', [ + 'foreignKey' => 'product_id', + 'className' => 'CakeProducts.ProductPhotos', + 'dependent' => true, + 'cascadeCallbacks' => true, + ]); + + $this->hasOne('PrimaryProductPhotos', [ + 'foreignKey' => 'product_id', + 'conditions' => ['PrimaryProductPhotos.primary_photo' => true], + 'className' => 'CakeProducts.ProductPhotos', + 'dependent' => true, + ]); + $this->getSchema()->setColumnType('product_type_id', EnumType::from(ProductProductTypeId::class)); $this->addBehavior('Muffin/Trash.Trash');