| 1 | 2 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | |||
| 3 | package Interchange6::Schema::Result::Cart; | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | Interchange6::Schema::Result::Cart | ||
| 8 | |||
| 9 | =cut | ||
| 10 | |||
| 11 | 2 | use Interchange6::Schema::Candy -components => | |
| 12 | 2 | ▶ | [qw(InflateColumn::DateTime TimeStamp)]; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | =head1 DESCRIPTION | ||
| 15 | |||
| 16 | The Cart class (table) is used for storing shopping carts with products in the | ||
| 17 | cart held in the related L<Interchange6::Schema::Result::CartProduct> class. | ||
| 18 | |||
| 19 | =head1 ACCESSORS | ||
| 20 | |||
| 21 | =head2 carts_id | ||
| 22 | |||
| 23 | Primary key. | ||
| 24 | |||
| 25 | =cut | ||
| 26 | |||
| 27 | 2 | primary_column carts_id => { | |
| 28 | data_type => "integer", | ||
| 29 | is_auto_increment => 1, | ||
| 30 | sequence => "carts_carts_id_seq", | ||
| 31 | }; | ||
| 32 | |||
| 33 | =head2 name | ||
| 34 | |||
| 35 | The name of the cart. You might perhaps have a "main" cart that is used by | ||
| 36 | default for the current shopping session and also a "wishlist" cart. Other | ||
| 37 | uses might be "saved_items" so a user can save things for another time or | ||
| 38 | maybe on logout all cart items are moved to "previous_session" cart. | ||
| 39 | |||
| 40 | =cut | ||
| 41 | |||
| 42 | 2 | column name => { | |
| 43 | data_type => "varchar", | ||
| 44 | default_value => "", | ||
| 45 | size => 255, | ||
| 46 | }; | ||
| 47 | |||
| 48 | =head2 users_id | ||
| 49 | |||
| 50 | Foreign key constraint on L<Interchange6::Schema::Result::User/users_id> | ||
| 51 | via L</user> relationship. | ||
| 52 | |||
| 53 | =cut | ||
| 54 | |||
| 55 | 2 | column users_id => { | |
| 56 | data_type => "integer", | ||
| 57 | is_foreign_key => 1, | ||
| 58 | is_nullable => 1, | ||
| 59 | }; | ||
| 60 | |||
| 61 | =head2 sessions_id | ||
| 62 | |||
| 63 | Foreign key constraint on L<Interchange6::Schema::Result::Session/sessions_id> | ||
| 64 | via L</session> relationship. Is nullable. | ||
| 65 | |||
| 66 | =cut | ||
| 67 | |||
| 68 | 2 | column sessions_id => { | |
| 69 | data_type => "varchar", | ||
| 70 | is_foreign_key => 1, | ||
| 71 | is_nullable => 1, | ||
| 72 | size => 255, | ||
| 73 | }; | ||
| 74 | |||
| 75 | =head2 created | ||
| 76 | |||
| 77 | Date and time when this record was created returned as L<DateTime> object. | ||
| 78 | Value is auto-set on insert. | ||
| 79 | |||
| 80 | =cut | ||
| 81 | |||
| 82 | 2 | column created => { | |
| 83 | data_type => "datetime", | ||
| 84 | set_on_create => 1, | ||
| 85 | }; | ||
| 86 | |||
| 87 | =head2 last_modified | ||
| 88 | |||
| 89 | Date and time when this record was last modified returned as L<DateTime> object. | ||
| 90 | Value is auto-set on insert and update. | ||
| 91 | |||
| 92 | =cut | ||
| 93 | |||
| 94 | 2 | column last_modified => { | |
| 95 | data_type => "datetime", | ||
| 96 | set_on_create => 1, | ||
| 97 | set_on_update => 1, | ||
| 98 | }; | ||
| 99 | |||
| 100 | =head1 UNIQUE CONSTRAINTS | ||
| 101 | |||
| 102 | =head2 carts_name_sessions_id | ||
| 103 | |||
| 104 | On ( name, sessions_id ) | ||
| 105 | |||
| 106 | =cut | ||
| 107 | |||
| 108 | 2 | unique_constraint carts_name_sessions_id => [qw/ name sessions_id /]; | |
| 109 | |||
| 110 | =head1 RELATIONS | ||
| 111 | |||
| 112 | =head2 cart_products | ||
| 113 | |||
| 114 | Type: has_many | ||
| 115 | |||
| 116 | Related object: L<Interchange6::Schema::Result::CartProduct> | ||
| 117 | |||
| 118 | =cut | ||
| 119 | |||
| 120 | 2 | has_many | |
| 121 | cart_products => "Interchange6::Schema::Result::CartProduct", | ||
| 122 | { "foreign.carts_id" => "self.carts_id" }, | ||
| 123 | { cascade_copy => 0, cascade_delete => 0 }; | ||
| 124 | |||
| 125 | =head2 session | ||
| 126 | |||
| 127 | Type: belongs_to | ||
| 128 | |||
| 129 | Related object: L<Interchange6::Schema::Result::Session> | ||
| 130 | |||
| 131 | =cut | ||
| 132 | |||
| 133 | 2 | belongs_to | |
| 134 | session => "Interchange6::Schema::Result::Session", | ||
| 135 | { sessions_id => "sessions_id" }, | ||
| 136 | { | ||
| 137 | is_deferrable => 1, | ||
| 138 | on_delete => "CASCADE", | ||
| 139 | on_update => "CASCADE", | ||
| 140 | join_type => "left" | ||
| 141 | }; | ||
| 142 | |||
| 143 | =head2 user | ||
| 144 | |||
| 145 | Type: belongs_to | ||
| 146 | |||
| 147 | Related object: L<Interchange6::Schema::Result::User> | ||
| 148 | |||
| 149 | =cut | ||
| 150 | |||
| 151 | 2 | belongs_to | |
| 152 | user => "Interchange6::Schema::Result::User", | ||
| 153 | { users_id => "users_id" }, | ||
| 154 | { | ||
| 155 | is_deferrable => 1, | ||
| 156 | on_delete => "CASCADE", | ||
| 157 | on_update => "CASCADE", | ||
| 158 | join_type => "left" | ||
| 159 | }; | ||
| 160 | |||
| 161 | 2 | 1; | |