-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9376f6f
commit e169627
Showing
4 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
database/migrations/phinx/20241101041234_create_phone_field_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class CreatePhoneFieldTable extends AbstractMigration | ||
{ | ||
/** | ||
* Change Method. | ||
* | ||
* Write your reversible migrations using this method. | ||
* | ||
* More information on writing migrations is available here: | ||
* https://book.cakephp.org/phinx/0/en/migrations.html | ||
* | ||
* The following commands can be used in this method and Phinx will | ||
* automatically reverse them when rolling back: | ||
* | ||
* createTable | ||
* renameTable | ||
* addColumn | ||
* addCustomColumn | ||
* renameColumn | ||
* addIndex | ||
* addForeignKey | ||
* | ||
* Any other destructive changes will result in an error when trying to | ||
* rollback the migration. | ||
* | ||
* Remember to call "create()" or "update()" and NOT "save()" when working | ||
* with the Table class. | ||
*/ | ||
public function change() | ||
{ | ||
$this->table('post_phone') | ||
->addColumn('post_id', 'integer') | ||
->addColumn('form_attribute_id', 'integer') | ||
->addColumn('value', 'string', [ | ||
'limit' => 32, | ||
]) | ||
->addColumn('created', 'integer', ['default' => 0]) | ||
->addForeignKey('post_id', 'posts', 'id', [ | ||
'delete' => 'CASCADE', | ||
'update' => 'CASCADE', | ||
]) | ||
->create(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Ushahidi\Modules\V5\Models\PostValues; | ||
|
||
class PostPhone extends PostValue | ||
{ | ||
public $table = 'post_phone'; | ||
|
||
/** | ||
* Get the error messages for the defined validation rules. | ||
* | ||
* @return array | ||
*/ | ||
public function validationMessages() | ||
{ | ||
return [ | ||
]; | ||
}//end validationMessages() | ||
|
||
/** | ||
* Return all validation rules | ||
* | ||
* @return array | ||
*/ | ||
public function getRules() | ||
{ | ||
$rules = [ | ||
'value' => ['string', 'max:32'], | ||
]; | ||
return array_merge(parent::getRules(), $rules); | ||
}//end getRules() | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function getValueAttribute($value) | ||
{ | ||
return $value; | ||
} | ||
}//end class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -264,6 +264,7 @@ private function postMethodRules() | |
'title', | ||
'description', | ||
'tags', | ||
'phone', | ||
] | ||
) | ||
], | ||
|