public static function initialize(Jam_Meta $meta) { $meta->table('vocabularies')->name_key('name'); $meta->behaviors(array('paranoid' => Jam::behavior('paranoid', array()))); $meta->associations(array('terms' => Jam::association('hasmany', array('inverse_of' => 'vocabulary')))); $meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'is_hidden' => Jam::field('boolean', array()), 'created_at' => Jam::field('timestamp', array('auto_now_create' => TRUE, 'format' => 'Y-m-d H:i:s')), 'updated_at' => Jam::field('timestamp', array('auto_now_update' => TRUE, 'format' => 'Y-m-d H:i:s', 'label' => "Last edited")))); }
public static function initialize(Jam_Meta $meta) { $meta->table('terms')->name_key('name'); $meta->behaviors(array('nested' => Jam::behavior('Nested'), 'sluggable' => Jam::behavior('Sluggable', array('uses_primary_key' => FALSE, 'auto_save' => FALSE, 'unique' => TRUE)))); $meta->associations(array('vocabulary' => Jam::association('belongsto', array('inverse_of' => 'terms')))); $meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'is_hidden' => Jam::field('boolean', array()), 'created_at' => Jam::field('timestamp', array('auto_now_create' => TRUE, 'format' => 'Y-m-d H:i:s')), 'updated_at' => Jam::field('timestamp', array('auto_now_update' => TRUE, 'format' => 'Y-m-d H:i:s')))); $meta->validator('name', array('present' => TRUE)); }
/** * @codeCoverageIgnore */ public static function initialize(Jam_Meta $meta) { $meta->table('purchase_items')->behaviors(array('paranoid' => Jam::behavior('paranoid')))->associations(array('brand_purchase' => Jam::association('belongsto', array('inverse_of' => 'items')), 'reference' => Jam::association('belongsto', array('foreign_key' => 'reference_id', 'polymorphic' => 'reference_model')), 'refund_items' => Jam::association('hasmany', array('foreign_model' => 'brand_refund_item', 'foreign_key' => 'purchase_item_id', 'inverse_of' => 'purchase_item'))))->fields(array('id' => Jam::field('primary'), 'model' => Jam::field('polymorphic'), 'quantity' => Jam::field('integer', array('default' => 1)), 'price' => Jam::field('price'), 'is_payable' => Jam::field('boolean'), 'is_discount' => Jam::field('boolean'), 'is_frozen' => Jam::field('boolean'), 'created_at' => Jam::field('timestamp', array('auto_now_create' => TRUE, 'format' => 'Y-m-d H:i:s')), 'updated_at' => Jam::field('timestamp', array('auto_now_update' => TRUE, 'format' => 'Y-m-d H:i:s'))))->validator('model', 'quantity', array('present' => TRUE))->validator('price', array('price' => array('greater_than_or_equal_to' => 0), 'unless' => 'is_discount'))->validator('price', array('price' => array('less_than_or_equal_to' => 0), 'if' => 'is_discount'))->validator('quantity', array('numeric' => array('only_integer' => TRUE, 'greater_than' => 0))); }
/** * @codeCoverageIgnore */ public static function initialize(Jam_Meta $meta) { $meta->table('shipping_external_data')->fields(array('id' => Jam::field('primary'), 'key' => Jam::field('string'), 'price' => Jam::field('price'), 'delivery_time' => Jam::field('range', array('format' => 'Model_Shipping::format_shipping_time'))))->name_key('key')->validator('price', 'key', 'delivery_time', array('present' => TRUE))->validator('key', array('unique' => TRUE))->validator('delivery_time', array('range' => array('consecutive' => TRUE, 'greater_than_or_equal_to' => 0))); }
/** * @codeCoverageIgnore */ public static function initialize(Jam_Meta $meta) { $meta->table('payments')->behaviors(array('paranoid' => Jam::behavior('paranoid'), 'payment_refundable' => Jam::behavior('payment_refundable')))->associations(array('purchase' => Jam::association('belongsto', array('inverse_of' => 'payment'))))->fields(array('id' => Jam::field('primary'), 'method' => Jam::field('string'), 'payment_id' => Jam::field('string'), 'raw_response' => Jam::field('serialized', array('method' => 'json')), 'status' => Jam::field('string'), 'created_at' => Jam::field('timestamp', array('auto_now_create' => TRUE, 'format' => 'Y-m-d H:i:s')), 'updated_at' => Jam::field('timestamp', array('auto_now_update' => TRUE, 'format' => 'Y-m-d H:i:s'))))->validator('purchase', 'method', array('present' => TRUE)); }