Exemplo n.º 1
0
Arquivo: Video.php Projeto: Konro1/pms
 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)));
 }
Exemplo n.º 2
0
Arquivo: Post.php Projeto: Konro1/pms
 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'));
 }
Exemplo n.º 3
0
 /**
  * @codeCoverageIgnore
  */
 public static function initialize(Jam_Meta $meta)
 {
     $meta->name_key('number')->behaviors(array('tokenable' => Jam::behavior('tokenable', array('uppercase' => TRUE, 'field' => 'number')), 'paranoid' => Jam::behavior('paranoid')))->associations(array('purchase' => Jam::association('belongsto', array('inverse_of' => 'brand_purchases')), 'items' => Jam::association('hasmany', array('inverse_of' => 'brand_purchase', 'foreign_model' => 'purchase_item', 'delete_on_remove' => Jam_Association::DELETE, 'dependent' => Jam_Association::DELETE)), 'refunds' => Jam::association('hasmany', array('inverse_of' => 'brand_purchase', 'foreign_model' => 'brand_refund', 'delete_on_remove' => Jam_Association::DELETE, 'dependent' => Jam_Association::DELETE)), 'brand' => Jam::association('belongsto', array('inverse_of' => 'brand_purchases'))))->fields(array('id' => Jam::field('primary'), '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('purchase', 'brand', array('present' => TRUE));
 }
Exemplo n.º 4
0
Arquivo: User.php Projeto: Konro1/pms
 public static function initialize(Jam_Meta $meta)
 {
     $meta->name_key('username')->associations(array('user_tokens' => Jam::association('hasmany'), 'roles' => Jam::association('manytomany')))->fields(array('id' => Jam::field('primary'), 'email' => Jam::field('string', array('label' => 'email address')), 'username' => Jam::field('string'), 'password' => Jam::field('password', array('hash_with' => array(Auth::instance(), 'hash'))), 'logins' => Jam::field('integer', array('default' => 0, 'convert_empty' => TRUE, 'empty_value' => 0)), 'last_login' => Jam::field('timestamp'), 'facebook_uid' => Jam::field('string'), 'twitter_uid' => Jam::field('string'), 'last_login_ip' => Jam::field('string', array('label' => 'Last logged from'))))->validator('email', array('format' => array('email' => TRUE), 'unique' => TRUE))->validator('username', array('length' => array('minimum' => 3, 'maximum' => 32), 'present' => TRUE, 'format' => array('regex' => '/^[a-zA-Z0-9\\_\\-]+$/')))->validator('password', array('length' => array('minimum' => 5, 'maximum' => 30), 'if' => 'validate_password'))->validator('last_login_ip', array('format' => array('filter' => FILTER_VALIDATE_IP)))->validator('password', array('if' => 'validate_password', 'present' => TRUE, 'confirmed' => TRUE))->validator('password_confirmation', array('present' => TRUE, 'if' => 'validate_password'));
 }
Exemplo n.º 5
0
 /**
  * @codeCoverageIgnore
  */
 public static function initialize(Jam_Meta $meta)
 {
     $meta->name_key('number')->behaviors(array('tokenable' => Jam::behavior('tokenable', array('uppercase' => TRUE, 'field' => 'number')), 'paranoid' => Jam::behavior('paranoid')))->associations(array('brand_purchases' => Jam::association('hasmany', array('inverse_of' => 'purchase', 'foreign_model' => 'brand_purchase', 'delete_on_remove' => Jam_Association::DELETE, 'dependent' => Jam_Association::DELETE)), 'brands' => Jam::association('manytomany', array('join_table' => 'brand_purchases', 'readonly' => TRUE)), 'creator' => Jam::association('creator', array('required' => FALSE)), 'billing_address' => Jam::association('belongsto', array('foreign_model' => 'address', 'dependent' => Jam_Association::DELETE)), 'payment' => Jam::association('hasone', array('inverse_of' => 'purchase', 'dependent' => Jam_Association::DELETE))))->fields(array('id' => Jam::field('primary'), 'currency' => Jam::field('string'), 'monetary' => Jam::field('serialized'), '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('currency', array('currency' => TRUE));
 }
Exemplo n.º 6
0
 /**
  * @codeCoverageIgnore
  */
 public static function initialize(Jam_Meta $meta)
 {
     $meta->name_key('line1')->behaviors(array('location_parent' => Jam::behavior('location_parent', array('parents' => array('city' => 'country'))), 'paranoid' => Jam::behavior('paranoid')))->associations(array('purchase' => Jam::association('hasone'), 'city' => Jam::association('autocreate', array('foreign_model' => 'location', 'default_fields' => array('type' => 'city'))), 'country' => Jam::association('belongsto', array('foreign_model' => 'location')), 'purchase' => Jam::association('hasone')))->fields(array('id' => Jam::field('primary'), 'first_name' => Jam::field('string'), 'last_name' => Jam::field('string'), 'email' => Jam::field('string'), 'phone' => Jam::field('string'), 'zip' => Jam::field('string'), 'line1' => Jam::field('string'), 'line2' => Jam::field('string'), 'state' => Jam::field('string'), 'fax' => Jam::field('string'), 'fields_required' => Jam::field('boolean', array('in_db' => FALSE))))->validator('first_name', 'last_name', 'city', 'country', 'email', 'line1', 'zip', 'phone', array('if' => 'fields_required', 'present' => TRUE))->validator('email', array('format' => array('email' => TRUE)));
 }
Exemplo n.º 7
0
Arquivo: Token.php Projeto: Konro1/pms
 public static function initialize(Jam_Meta $meta)
 {
     $meta->name_key('token')->behaviors(array('auth_user_token' => Jam::behavior('auth_user_token')))->fields(array('id' => Jam::field('primary'), 'user_agent' => Jam::field('string'), 'token' => Jam::field('string'), 'type' => Jam::field('string'), 'created' => Jam::field('timestamp', array('auto_now_create' => TRUE)), 'expires' => Jam::field('timestamp', array('filters' => array('Model_Auth_User_Token::convert_expires')))))->associations(array('user' => Jam::association('belongsto')))->validator('token', array("unique" => TRUE));
 }
Exemplo n.º 8
0
 /**
  * @codeCoverageIgnore
  */
 public static function initialize(Jam_Meta $meta)
 {
     $meta->name_key('code')->unique_key(function ($key) {
         return is_string($key) ? 'code' : 'id';
     })->behaviors(array('tokenable' => Jam::behavior('tokenable', array('field' => 'code', 'uppercase' => TRUE))))->associations(array('purchases' => Jam::association('hasmany', array('inverse_of' => 'promo_code', 'foreign_model' => 'purchase')), 'promotion' => Jam::association('belongsto', array('inverse_of' => 'promo_codes'))))->fields(array('id' => Jam::field('primary'), 'origin' => Jam::field('string'), 'allow_multiple' => Jam::field('boolean'), 'created_at' => Jam::field('timestamp', array('auto_now_create' => TRUE, 'format' => 'Y-m-d H:i:s')), 'expires_at' => Jam::field('timestamp', array('format' => 'Y-m-d H:i:s'))))->validator('promotion', 'origin', array('present' => TRUE));
 }
Exemplo n.º 9
0
Arquivo: Role.php Projeto: Konro1/pms
 public static function initialize(Jam_Meta $meta)
 {
     $meta->name_key('name')->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'description' => Jam::field('string')))->associations(array('users' => Jam::association('manytomany')))->validator('name', array('present' => TRUE, 'length' => array('minimum' => 4, 'maximum' => 32), 'unique' => TRUE))->validator('description', array('length' => array('maximum' => 255)));
 }
Exemplo n.º 10
0
 /**
  * Convert :primary_key, :name_kay and :unique_key to their corresponding column names
  * @param  string   $attribute
  * @param  Jam_Meta $meta
  * @param  mixed   $value
  * @return string
  */
 public static function resolve_meta_attribute($attribute, Jam_Meta $meta, $value = NULL)
 {
     switch ($attribute) {
         case ':primary_key':
             $attribute = $meta->primary_key();
             break;
         case ':name_key':
             $attribute = $meta->name_key();
             break;
         case ':unique_key':
             $attribute = $meta->unique_key($value);
             break;
     }
     return $attribute;
 }
Exemplo n.º 11
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')));
 }