Beispiel #1
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));
 }
Beispiel #2
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)));
 }
Beispiel #3
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)));
 }
Beispiel #4
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'));
 }
Beispiel #5
0
 public static function initialize(Jam_Meta $meta)
 {
     $meta->fields(array('email' => Jam::field('string'), 'password' => Jam::field('string'), 'remember_me' => Jam::field('boolean')));
     $meta->validator('email', 'password', array('present' => TRUE));
 }