- Adds new models: CustomFields and SubscriberCustomField + tests

- Adjusts DB Migrator, Initializer class
- Adjusts Subscribers model tests
Closes #159
This commit is contained in:
MrCasual
2015-10-15 23:11:43 -04:00
parent 4b581fcd5d
commit 805f7d5417
8 changed files with 257 additions and 42 deletions

View File

@ -0,0 +1,25 @@
<?php
namespace MailPoet\Models;
if(!defined('ABSPATH')) exit;
class CustomField extends Model {
public static $_table = MP_CUSTOM_FIELDS_TABLE;
function __construct() {
parent::__construct();
$this->addValidations('name', array(
'required' => __('You need to specify a name.')
));
}
function subscribers() {
return $this->has_many_through(
__NAMESPACE__ . '\Subscriber',
__NAMESPACE__ . '\SubscriberCustomField',
'custom_field_id',
'subscriber_id'
);
}
}