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"))));
 }
Exemple #2
0
 public static function initialize(Jam_Meta $meta)
 {
     // Set database to connect to
     $meta->db(Kohana::TESTING);
     $meta->associations(array('test_owner' => Jam::association('belongsto', array('foreign_model' => 'test_author', 'foreign_key' => 'test_owner_id')), 'test_featured_category' => Jam::association('hasone', array('foreign_model' => 'test_category')), 'test_posts' => Jam::association('hasmany', array('inverse_of' => 'test_blog', 'count_cache' => TRUE, 'dependent' => Jam_Association::DELETE)), 'test_categories' => Jam::association('hasmany', array('required' => TRUE, 'inverse_of' => 'test_blog')), 'test_tags' => Jam::association('manytomany', array())));
     // Define fields
     $meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'url' => Jam::field('weblink'), 'test_posts_count' => Jam::field('integer')));
 }
Exemple #3
0
 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));
 }
Exemple #4
0
 public static function initialize(Jam_Meta $meta)
 {
     // Set database to connect to
     $meta->db(Kohana::TESTING);
     $meta->associations(array('test_image' => Jam::association('belongsto', array('dependent' => Jam_Association::DELETE))));
     // Set fields
     $meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string')));
 }
Exemple #5
0
 public static function initialize(Jam_Meta $meta)
 {
     // Set database to connect to
     $meta->db(Kohana::TESTING);
     $meta->associations(array('test_post' => Jam::association('hasone', array('inverse_of' => 'test_author')), 'test_posts' => Jam::association('hasmany'), 'test_blogs_owned' => Jam::association('hasmany', array('foreign_model' => 'test_blog', 'foreign_key' => 'test_owner_id')), 'test_categories' => Jam::association('hasmany'), 'test_position' => Jam::association('belongsto'), 'permission' => Jam::association('belongsto', array('foreign_model' => 'test_position', 'foreign_key' => 'test_position_id'))));
     // Define fields
     $meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'password' => Jam::field('password'), 'email' => Jam::field('string')));
 }
Exemple #6
0
 public static function initialize(Jam_Meta $meta)
 {
     // Set database to connect to
     $meta->db(Kohana::TESTING);
     $meta->associations(array('test_holder' => Jam::association('belongsto', array('polymorphic' => TRUE)), 'test_copyright' => Jam::association('hasone', array('dependent' => Jam_Association::ERASE)), 'test_copyrights' => Jam::association('hasmany', array('dependent' => Jam_Association::ERASE))));
     // Set fields
     $meta->fields(array('id' => Jam::field('primary'), 'file' => Jam::field('upload', array('delete_file' => TRUE))));
 }
Exemple #7
0
 public static function initialize(Jam_Meta $meta)
 {
     // Set database to connect to
     $meta->db(Kohana::TESTING);
     $meta->behaviors(array('nested' => Jam::behavior('nested')));
     $meta->associations(array('test_blog' => Jam::association('belongsto', array('inverse_of' => 'test_categories')), 'test_posts' => Jam::association('manytomany'), 'test_author' => Jam::association('belongsto')));
     // Define fields
     $meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'is_featured' => Jam::field('boolean')));
 }
Exemple #8
0
 public static function initialize(Jam_Meta $meta)
 {
     // Set database to connect to
     $meta->db(Kohana::TESTING);
     $meta->associations(array('test_post' => Jam::association('belongsto', array('conditions' => array('where' => array('test_post._approved_by', 'IS', NULL)), 'counter_cache' => TRUE, 'touch' => 'updated')), 'test_blogs' => Jam::association('manytomany', array('join_table' => 'test_blogs_test_tags'))));
     $meta->behaviors(array('sluggable' => Jam::behavior('sluggable', array('uses_primary_key' => FALSE, 'unique' => TRUE, 'slug' => 'Model_Test_Tag::_slug'))));
     // Set fields
     $meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string')));
 }
Exemple #9
0
 public static function initialize(Jam_Meta $meta)
 {
     // Set database to connect to
     $meta->db(Kohana::TESTING);
     $meta->associations(array('test_author' => Jam::association('belongsto')));
     // Set fields
     $meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'url' => Jam::field('string'), 'email' => Jam::field('string'), 'description' => Jam::field('string'), 'amount' => Jam::field('integer')));
     $meta->validator('name', array('present' => TRUE))->validator('name', 'email', 'url', array('count' => array('minimum' => 2)))->validator('email', array('format' => array('filter' => FILTER_VALIDATE_EMAIL)))->validator('url', array('format' => array('filter' => FILTER_VALIDATE_URL)))->validator('amount', array('numeric' => array('greater_than' => 10, 'less_than' => 100)))->validator('description', array('length' => array('between' => array(10, 1000))))->validator('name', array('format' => array('filter' => FILTER_VALIDATE_IP), 'if' => 'name_is_ip'))->validator('name', array('length' => array('minimum' => 2)));
     $meta->with_options(array('unless' => 'name_is_normal()'))->validator('name', array('format' => array('filter' => FILTER_VALIDATE_EMAIL)));
 }
Exemple #10
0
 public static function initialize(Jam_Meta $meta)
 {
     // Set database to connect to
     $meta->db(Kohana::TESTING);
     $meta->name_key('file');
     $meta->behaviors(array('paranoid' => Jam::behavior('paranoid', array('field' => 'deleted')), 'sortable' => Jam::behavior('sortable', array('field' => 'position', 'scope' => 'group')), 'sluggable' => Jam::behavior('sluggable', array('auto_save' => TRUE)), 'tokenable' => Jam::behavior('tokenable', array('uppercase' => TRUE))));
     $meta->associations(array('test_holder' => Jam::association('belongsto', array('polymorphic' => 'test_holder_type'))));
     // Set fields
     $meta->fields(array('id' => Jam::field('primary'), 'file' => Jam::field('string'), 'group' => Jam::field('string')));
     $meta->validator('file', array('length' => array('minimum' => 4)));
 }
Exemple #11
0
 public static function initialize(Jam_Meta $meta)
 {
     // Set database to connect to
     $meta->db(Kohana::TESTING);
     // Posts always load_with an author
     //$meta->load_with(array('test_author'));
     $meta->name_key('name');
     $meta->associations(array('test_blog' => Jam::association('belongsto', array('inverse_of' => 'test_posts')), 'test_author' => Jam::association('belongsto', array()), 'test_tags' => Jam::association('hasmany', array('inverse_of' => 'test_post')), 'approved_by' => Jam::association('belongsto', array('foreign_model' => 'test_author', 'foreign_key' => '_approved_by')), 'test_images' => Jam::association('hasmany', array('as' => 'test_holder', 'dependent' => Jam_Association::DELETE)), 'test_cover_image' => Jam::association('hasone', array('as' => 'test_holder', 'foreign_model' => 'test_image', 'dependent' => Jam_Association::DELETE)), 'test_categories' => Jam::association('manytomany')));
     // Set fields
     $meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'slug' => Jam::field('slug', array('unique' => TRUE)), 'status' => Jam::field('string', array()), 'created' => Jam::field('timestamp', array('auto_now_create' => TRUE)), 'updated' => Jam::field('timestamp', array('auto_now_update' => TRUE))));
     // Set some custom validators
     $meta->validator('name', array('present' => TRUE, 'if' => 'slug'));
 }
Exemple #12
0
 /**
  * @codeCoverageIgnore
  */
 public static function initialize(Jam_Meta $meta)
 {
     $meta->associations(array('brand' => Jam::association('belongsto', array('inverse_of' => 'shipping_methods')), 'shippings' => Jam::association('manytomany', array('foreign_key' => 'method_id', 'join_table' => 'shipping_groups', 'readonly' => TRUE)), 'shipping_groups' => Jam::association('hasmany', array('inverse_of' => 'method'))))->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string')))->validator('name', array('present' => TRUE));
 }
Exemple #13
0
 public static function initialize(Jam_Meta $meta)
 {
     $meta->associations(array('product' => Jam::association('belongsto')))->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'price' => Jam::field('float')))->validator('name', 'price', 'product', array('present' => TRUE))->validator('price', array('numeric' => TRUE));
 }
Exemple #14
0
 /**
  * @codeCoverageIgnore
  */
 public static function initialize(Jam_Meta $meta)
 {
     $meta->associations(array('brand_purchase_shipping' => Jam::association('belongsto', array('inverse_of' => 'items')), 'purchase_item' => Jam::association('belongsto', array('inverse_of' => 'shipping_item', 'foreign_key' => 'purchase_item_id', 'foreign_model' => 'purchase_item_product')), 'shipping_group' => Jam::association('belongsto', array('inverse_of' => 'shipping_items'))))->fields(array('id' => Jam::field('primary'), 'model' => Jam::field('polymorphic'), 'total_delivery_time' => Jam::field('range', array('format' => 'Model_Shipping::format_shipping_time')), 'is_frozen' => Jam::field('boolean')))->validator('purchase_item', array('present' => TRUE));
 }
Exemple #15
0
 /**
  * @codeCoverageIgnore
  */
 public static function initialize(Jam_Meta $meta)
 {
     $meta->associations(array('brand_purchase' => Jam::association('belongsto', array('inverse_of' => 'shipping')), 'items' => Jam::association('hasmany', array('foreign_model' => 'shipping_item', 'inverse_of' => 'brand_purchase_shipping', 'delete_on_remove' => Jam_Association::DELETE, 'dependent' => Jam_Association::DELETE))))->fields(array('id' => Jam::field('primary'), 'is_frozen' => Jam::field('boolean')))->validator('brand_purchase', 'items', array('present' => TRUE));
 }
Exemple #16
0
 public static function initialize(Jam_Meta $meta)
 {
     $meta->associations(array('variations' => Jam::association('hasmany')))->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'currency' => Jam::field('string'), 'price' => Jam::field('price')))->validator('name', 'price', 'currency', array('present' => TRUE))->validator('price', array('price' => TRUE));
 }
Exemple #17
0
 public static function initialize(Jam_Meta $meta)
 {
     $meta->associations(array('shipping' => Jam::association('belongsto', array('inverse_of' => 'products')), 'brand' => Jam::association('belongsto'), 'variations' => Jam::association('hasmany'), 'purchase_items' => Jam::association('hasmany', array('as' => 'reference'))))->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'currency' => Jam::field('string'), 'price' => Jam::field('price')))->validator('name', 'price', 'currency', array('present' => TRUE))->validator('price', array('numeric' => TRUE));
 }
Exemple #18
0
 public static function initialize(Jam_Meta $meta)
 {
     $meta->associations(array('styles' => Jam::association('taxonomy_terms', array('vocabulary' => 'Styles')), 'types' => Jam::association('taxonomy_terms', array('vocabulary' => 'Types'))));
     // Define fields
     $meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string')));
 }
Exemple #19
0
 public static function initialize(Jam_Meta $meta)
 {
     $meta->name_key('id');
     $meta->associations(array('term' => Jam::association('belongsto'), 'item' => Jam::association('belongsto', array('polymorphic' => TRUE))));
     $meta->fields(array('id' => Jam::field('primary')));
 }