associations saving many to many workign now catalogs
This commit is contained in:
@@ -3,8 +3,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Table;
|
||||
|
||||
use ArrayObject;
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\Event\EventInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Behavior\TimestampBehavior;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
@@ -55,6 +58,9 @@ class ExternalProductCatalogsProductCatalogsTable extends Table
|
||||
|
||||
$this->addBehavior('Timestamp');
|
||||
|
||||
$this->setEntityClass(
|
||||
Configure::read('CakeProducts.ExternalProductCatalogsProductCatalogs.entity', 'CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog')
|
||||
);
|
||||
$this->belongsTo('ExternalProductCatalogs', [
|
||||
'className' => 'CakeProducts.ExternalProductCatalogs',
|
||||
// 'foreignKey' => 'external_product_catalog_id',
|
||||
@@ -84,13 +90,18 @@ class ExternalProductCatalogsProductCatalogsTable extends Table
|
||||
->notEmptyString('product_catalog_id');
|
||||
|
||||
$validator
|
||||
->boolean('enabled')
|
||||
->requirePresence('enabled', 'create')
|
||||
->notEmptyString('enabled');
|
||||
->boolean('enabled');
|
||||
|
||||
return $validator;
|
||||
}
|
||||
|
||||
public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options)
|
||||
{
|
||||
if (!isset($data['enabled'])) {
|
||||
$data['enabled'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
|
||||
Reference in New Issue
Block a user