コード例 #1
0
 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"))));
 }
コード例 #2
0
ファイル: User.php プロジェクト: openbuildings/jam-auth
 public static function initialize(Jam_Meta $meta)
 {
     $meta->db(Kohana::TESTING);
     parent::initialize($meta);
     $meta->behaviors(['username' => Jam::behavior('username')]);
     $meta->associations(array('user_tokens' => Jam::association('hasmany', array('foreign_model' => 'test_user_token', 'foreign_key' => 'test_user_id')), 'roles' => Jam::association('manytomany', array('foreign_model' => 'test_role', 'join_table' => 'test_roles_users', 'foreign_key' => 'test_role_id', 'association_foreign_key' => 'test_user_id'))));
 }
コード例 #3
0
ファイル: Term.php プロジェクト: openbuildings/jam-taxonomy
 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));
 }
コード例 #4
0
 /**
  * @covers Jam_Behavior_Promotable_Brand_Purchase::available_promotions
  */
 public function test_available_promotions()
 {
     $behavior = Jam::behavior('promotable_brand_purchase');
     $promotions = $behavior->available_promotions();
     $this->assertEquals(array(1, 2), $promotions->ids());
     Jam::find('promotion', 1)->update_fields(array('expires_at' => strtotime('-2days')));
     $promotions = $behavior->available_promotions();
     $this->assertEquals(array(2), $promotions->ids());
 }
コード例 #5
0
ファイル: Tag.php プロジェクト: Konro1/pms
 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')));
 }
コード例 #6
0
ファイル: Category.php プロジェクト: Konro1/pms
 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')));
 }
コード例 #7
0
ファイル: Video.php プロジェクト: 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)));
 }
コード例 #8
0
ファイル: Child.php プロジェクト: openbuildings/jam-freezable
 public static function initialize(Jam_Meta $meta)
 {
     $meta->behaviors(array('freezable' => Jam::behavior('freezable', array('parent' => 'test', 'fields' => 'value'))))->associations(array('parent' => Jam::association('belongsto')))->fields(array('value' => Jam::field('string')));
 }
コード例 #9
0
ファイル: Item.php プロジェクト: openbuildings/purchases
 /**
  * @codeCoverageIgnore
  */
 public static function initialize(Jam_Meta $meta)
 {
     $meta->behaviors(array('paranoid' => Jam::behavior('paranoid')))->associations(array('brand_refund' => Jam::association('belongsto', array('inverse_of' => 'items')), 'purchase_item' => Jam::association('belongsto', array('inverse_of' => 'refund_items'))))->fields(array('id' => Jam::field('primary'), 'amount' => Jam::field('price')))->validator('brand_refund', 'purchase_item', array('present' => TRUE));
 }
コード例 #10
0
ファイル: Brand.php プロジェクト: openbuildings/shipping
 public static function initialize(Jam_Meta $meta)
 {
     $meta->behaviors(array('shippable_brand' => Jam::behavior('shippable_brand')))->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string')));
 }
コード例 #11
0
ファイル: Shipping.php プロジェクト: openbuildings/shipping
 /**
  * @codeCoverageIgnore
  */
 public static function initialize(Jam_Meta $meta)
 {
     $meta->behaviors(array('paranoid' => Jam::behavior('paranoid')))->associations(array('groups' => Jam::association('hasmany', array('foreign_model' => 'shipping_group', 'foreign_key' => 'shipping_id', 'inverse_of' => 'shipping', 'delete_on_remove' => Jam_Association::DELETE)), 'methods' => Jam::association('manytomany', array('foreign_model' => 'shipping_method', 'association_foreign_key' => 'method_id', 'join_table' => 'shipping_groups', 'readonly' => TRUE, 'join_table_paranoid' => TRUE)), 'locations' => Jam::association('manytomany', array('join_table' => 'shipping_groups', 'join_table_paranoid' => TRUE, 'readonly' => TRUE)), 'ships_from' => Jam::association('belongsto', array('foreign_model' => 'location')), 'brand' => Jam::association('belongsto', array('inverse_of' => 'shippings'))))->fields(array('id' => Jam::field('primary'), 'model' => Jam::field('polymorphic'), 'name' => Jam::field('string'), 'currency' => Jam::field('string')))->validator('name', 'currency', array('present' => TRUE))->validator('currency', array('currency' => TRUE));
 }
コード例 #12
0
 /**
  * @codeCoverageIgnore
  */
 public static function initialize(Jam_Meta $meta)
 {
     $meta->behaviors(array('visitor_defaults' => Jam::behavior('visitor_defaults')))->associations(array('user' => Jam::association('belongsto', array('inverse_of' => 'visitor')), 'country' => Jam::association('belongsto', array('foreign_key' => 'country_id', 'foreign_model' => 'location'))))->fields(array('id' => Jam::field('primary'), 'ip' => Jam::field('ip'), 'token' => Jam::field('string'), 'currency' => Jam::field('string')))->validator('currency', array('choice' => array('in' => array('EUR', 'GBP'))));
 }
コード例 #13
0
ファイル: Test.php プロジェクト: openbuildings/jam-freezable
 public static function initialize(Jam_Meta $meta)
 {
     $meta->behaviors(array('freezable' => Jam::behavior('freezable', array('associations' => 'child'))))->associations(array('child' => Jam::association('hasone')));
 }
コード例 #14
0
ファイル: Product.php プロジェクト: openbuildings/purchases
 public static function initialize(Jam_Meta $meta)
 {
     $meta->behaviors(array('paranoid' => Jam::behavior('paranoid')))->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));
 }
コード例 #15
0
ファイル: Token.php プロジェクト: 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));
 }
コード例 #16
0
ファイル: Group.php プロジェクト: openbuildings/shipping
 /**
  * @codeCoverageIgnore
  */
 public static function initialize(Jam_Meta $meta)
 {
     $meta->behaviors(array('paranoid' => Jam::behavior('paranoid')))->associations(array('shipping' => Jam::association('belongsto', array('inverse_of' => 'locations')), 'method' => Jam::association('belongsto', array('foreign_model' => 'shipping_method', 'inverse_of' => 'locations')), 'location' => Jam::association('belongsto', array('inverse_of' => 'shipping_group')), 'shipping_items' => Jam::association('hasmany', array('inverse_of' => 'shipping_group'))))->fields(array('id' => Jam::field('primary'), 'price' => Jam::field('price'), 'delivery_time' => Jam::field('range', array('format' => 'Model_Shipping::format_shipping_time')), 'additional_item_price' => Jam::field('price', array('convert_empty' => FALSE)), 'discount_threshold' => Jam::field('price')))->validator('price', 'shipping', 'location', 'method', 'delivery_time', array('present' => TRUE))->validator('additional_item_price', 'discount_threshold', 'price', array('price' => array('greater_than_or_equal_to' => 0)))->validator('delivery_time', array('range' => array('consecutive' => TRUE, 'greater_than_or_equal_to' => 0)));
 }
コード例 #17
0
ファイル: Item.php プロジェクト: openbuildings/purchases
 /**
  * @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)));
 }
コード例 #18
0
ファイル: Purchase.php プロジェクト: openbuildings/promotions
 public static function initialize(Jam_Meta $meta)
 {
     parent::initialize($meta);
     $meta->behaviors(array('promotable_brand_purchase' => Jam::behavior('promotable_brand_purchase')));
 }
コード例 #19
0
ファイル: User.php プロジェクト: openbuildings/jam-locations
 public static function initialize(Jam_Meta $meta)
 {
     $meta->behaviors(array('location_auto' => Jam::behavior('location_auto', array('locations' => array('city' => 'city', 'country' => 'country_name')))))->associations(array('country' => Jam::association('belongsto', array('foreign_model' => 'location')), 'city' => Jam::association('belongsto', array('foreign_model' => 'location'))))->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'ip' => Jam::field('ip')));
 }
コード例 #20
0
 /**
  * @codeCoverageIgnore
  */
 public static function initialize(Jam_Meta $meta)
 {
     $meta->behaviors(array('closuretable' => Jam::behavior('closuretable')))->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'short_name' => Jam::field('string'), 'type' => Jam::field('string')))->validator('name', array('present' => TRUE));
 }
コード例 #21
0
 public static function initialize(Jam_Meta $meta)
 {
     $meta->behaviors(array('freezable' => Jam::behavior('freezable', array('fields' => 'monetary', 'associations' => array('test_store_purchases', 'test_payment')))))->associations(array('test_store_purchases' => Jam::association('hasmany', array('inverse_of' => 'test_purchase', 'foreign_model' => 'test_store_purchase')), 'test_payment' => Jam::association('hasone')))->fields(array('id' => Jam::field('primary'), 'monetary' => Jam::field('serialized')));
 }
コード例 #22
0
 public static function initialize(Jam_Meta $meta)
 {
     $meta->behaviors(array('freezable' => Jam::behavior('freezable', array('skippable' => 'is_meldable', 'skippable_field_options' => array('default' => TRUE)))));
 }
コード例 #23
0
 public static function initialize(Jam_Meta $meta)
 {
     $meta->behaviors(array('materializedpath' => Jam::behavior('materializedpath')))->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string')));
 }
コード例 #24
0
ファイル: Address.php プロジェクト: openbuildings/purchases
 /**
  * @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)));
 }
コード例 #25
0
ファイル: Purchase.php プロジェクト: openbuildings/purchases
 /**
  * @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));
 }
コード例 #26
0
ファイル: Purchase.php プロジェクト: openbuildings/purchases
 /**
  * @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));
 }
コード例 #27
0
ファイル: User.php プロジェクト: openbuildings/site-versions
 public static function initialize(Jam_Meta $meta)
 {
     parent::initialize($meta);
     $meta->behaviors(array('visitor_user' => Jam::behavior('visitor_user')));
 }
コード例 #28
0
ファイル: Product.php プロジェクト: openbuildings/shipping
 public static function initialize(Jam_Meta $meta)
 {
     parent::initialize($meta);
     $meta->behaviors(array('shippable_purchase_item' => Jam::behavior('shippable_purchase_item')));
 }
コード例 #29
0
 public static function initialize(Jam_Meta $meta)
 {
     $meta->db(Kohana::TESTING);
     $meta->behaviors(array('closuretable' => Jam::behavior('closuretable', array('children_dependent' => Jam_Association::DELETE))))->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string')));
 }
コード例 #30
0
ファイル: Event.php プロジェクト: openbuildings/jam-taxonomy
 public static function initialize(Jam_Meta $meta)
 {
     $meta->behaviors(array('taxonomable' => Jam::behavior('taxonomable')));
     // Define fields
     $meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string')));
 }