sah-comp / ksm

Application for lending, selling and maintaining forklifts.
0 stars 0 forks source link

Failing validator hasValue when using (migrated) data #12

Closed sah-comp closed 3 years ago

sah-comp commented 4 years ago

e.g. a contract has no selected contracttype. When updating the machine bean used in that contract the validator hasValue on attribute name of contracttype fails because there is no name set.

sah-comp commented 4 years ago

For now I have dropped the validator hasName, thus allowing a empty contracttype.name in a contract. Once the (empty) name contracttype bean was created one can name it "Empty" and all things are good.

sah-comp commented 3 years ago

The constant CINNEBAR_MIP was introduced. When not migrating it is set to false, otherwise it is set to true.

This way a model can use something like the following code in its update function without jepardizing the correct column type guessing by RedBeanPHP while migrating. Before this the migrator was not able to have machine become a relation.

if (!CINNEBAR_MIP) {
  if (!$this->bean->machine_id) {
    unset($this->bean->machine);
  }
}