Skip to content

Commit

Permalink
add unique on invitetranslations - language_id #59
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickakk committed Nov 9, 2024
1 parent 292fb8b commit b3973ca
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Version 2024-12
*Release date: ...*

### Change
- xyz
### Changes
- Added unique validation for invite translation - language id #59


## Version 2024-11
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use Migrations\AbstractMigration;

class AddLanguageIdIndexToInviteTranslations extends AbstractMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
* @return void
*/
public function change(): void
{
$table = $this->table('invite_translations');
$table->addIndex('language_id', ['unique' => true]);
$table->update();
}
}
1 change: 1 addition & 0 deletions src/Model/Table/InviteTranslationsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function validationDefault(Validator $validator): Validator
public function buildRules(RulesChecker $rules): RulesChecker
{
$rules->add($rules->isUnique(['sortOrder']), ['errorField' => 'sortOrder']);
$rules->add($rules->isUnique(['language_id']), ['errorField' => 'language_id']);
$rules->add($rules->existsIn(['language_id'], 'Languages'), ['errorField' => 'language_id']);

return $rules;
Expand Down

0 comments on commit b3973ca

Please sign in to comment.