unique rules, allow product id to be null in product photos
This commit is contained in:
parent
2041fc78d3
commit
d239a98e8e
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Migrations\BaseMigration;
|
||||||
|
|
||||||
|
class AllowProductIdToBeNullInProductPhotos extends BaseMigration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Change Method.
|
||||||
|
*
|
||||||
|
* More information on this method is available here:
|
||||||
|
* https://book.cakephp.org/migrations/4/en/migrations.html#the-change-method
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function change(): void
|
||||||
|
{
|
||||||
|
$table = $this->table('product_photos');
|
||||||
|
$table->changeColumn('product_id', 'uuid', [
|
||||||
|
'default' => null,
|
||||||
|
'limit' => 11,
|
||||||
|
'null' => true,
|
||||||
|
]);
|
||||||
|
$table->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,7 +10,7 @@ use Cake\ORM\Entity;
|
||||||
* ProductPhoto Entity
|
* ProductPhoto Entity
|
||||||
*
|
*
|
||||||
* @property string $id
|
* @property string $id
|
||||||
* @property string $product_id
|
* @property string|null $product_id
|
||||||
* @property string|null $product_category_id
|
* @property string|null $product_category_id
|
||||||
* @property string|null $product_sku_id
|
* @property string|null $product_sku_id
|
||||||
* @property string $photo_dir
|
* @property string $photo_dir
|
||||||
|
|
@ -55,6 +55,8 @@ class ProductPhoto extends Entity
|
||||||
'deleted' => true,
|
'deleted' => true,
|
||||||
|
|
||||||
// entities
|
// entities
|
||||||
'product' => true,
|
'product' => false,
|
||||||
|
'product_sku' => false,
|
||||||
|
'product_category' => false,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ class ProductCategoryAttributeOptionsTable extends Table
|
||||||
public function buildRules(RulesChecker $rules): RulesChecker
|
public function buildRules(RulesChecker $rules): RulesChecker
|
||||||
{
|
{
|
||||||
$rules->add($rules->existsIn(['product_category_attribute_id'], 'ProductCategoryAttributes'), ['errorField' => 'product_category_attribute_id']);
|
$rules->add($rules->existsIn(['product_category_attribute_id'], 'ProductCategoryAttributes'), ['errorField' => 'product_category_attribute_id']);
|
||||||
|
$rules->add($rules->isUnique(['attribute_value', 'product_category_attribute_id']));
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ class ProductCategoryVariantOptionsTable extends Table
|
||||||
public function buildRules(RulesChecker $rules): RulesChecker
|
public function buildRules(RulesChecker $rules): RulesChecker
|
||||||
{
|
{
|
||||||
$rules->add($rules->existsIn(['product_category_variant_id'], 'ProductCategoryVariants'), ['errorField' => 'product_category_variant_id']);
|
$rules->add($rules->existsIn(['product_category_variant_id'], 'ProductCategoryVariants'), ['errorField' => 'product_category_variant_id']);
|
||||||
|
$rules->add($rules->isUnique(['variant_value', 'product_category_variant_id']));
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue