| 1 | 2 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | |||
| 3 | package Interchange6::Schema::Result::CartProduct; | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | Interchange6::Schema::Result::CartProduct | ||
| 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 | Holds products for related L<Interchange6::Schema::Result::Cart> class and | ||
| 17 | links to the full product details held in L<Interchange6::Schema::Result::Product>. | ||
| 18 | |||
| 19 | =head1 ACCESSORS | ||
| 20 | |||
| 21 | =head2 cart_products_id | ||
| 22 | |||
| 23 | Primary key. | ||
| 24 | |||
| 25 | =cut | ||
| 26 | |||
| 27 | 2 | primary_column cart_products_id => { | |
| 28 | data_type => "integer", | ||
| 29 | is_auto_increment => 1, | ||
| 30 | sequence => "cart_product_cart_products_id_seq", | ||
| 31 | }; | ||
| 32 | |||
| 33 | =head2 carts_id | ||
| 34 | |||
| 35 | Foreign key constraint on L<Interchange6::Schema::Result::Cart/carts_id> | ||
| 36 | via L</cart> relationship. | ||
| 37 | |||
| 38 | =cut | ||
| 39 | |||
| 40 | 2 | column carts_id => { | |
| 41 | data_type => "integer", | ||
| 42 | }; | ||
| 43 | |||
| 44 | =head2 sku | ||
| 45 | |||
| 46 | Foreign key constraint on L<Interchange6::Schema::Result::Product/sku> | ||
| 47 | via L</product> relationship. | ||
| 48 | |||
| 49 | =cut | ||
| 50 | |||
| 51 | 2 | column sku => { | |
| 52 | data_type => "varchar", | ||
| 53 | size => 64, | ||
| 54 | }; | ||
| 55 | |||
| 56 | =head2 cart_position | ||
| 57 | |||
| 58 | Integer cart position. | ||
| 59 | |||
| 60 | =cut | ||
| 61 | |||
| 62 | 2 | column cart_position => { | |
| 63 | data_type => "integer", | ||
| 64 | }; | ||
| 65 | |||
| 66 | =head2 quantity | ||
| 67 | |||
| 68 | The integer quantity of product in the cart. Defaults to 1. | ||
| 69 | |||
| 70 | =cut | ||
| 71 | |||
| 72 | 2 | column quantity => { | |
| 73 | data_type => "integer", | ||
| 74 | default_value => 1, | ||
| 75 | }; | ||
| 76 | |||
| 77 | =head2 combine | ||
| 78 | |||
| 79 | Indicate whether products with the same SKU should be combined in the Cart | ||
| 80 | |||
| 81 | Defaults to true. | ||
| 82 | |||
| 83 | =cut | ||
| 84 | |||
| 85 | 2 | column combine => { | |
| 86 | data_type => "boolean", | ||
| 87 | default_value => 1, | ||
| 88 | }; | ||
| 89 | |||
| 90 | =head2 extra | ||
| 91 | |||
| 92 | Any extra info associated with this cart product. This could be used to store | ||
| 93 | special instructions for product like personalisation. | ||
| 94 | |||
| 95 | Is nullable. | ||
| 96 | |||
| 97 | =cut | ||
| 98 | |||
| 99 | 2 | column extra => { | |
| 100 | data_type => "text", | ||
| 101 | is_nullable => 1, | ||
| 102 | }; | ||
| 103 | |||
| 104 | =head2 created | ||
| 105 | |||
| 106 | Date and time when this record was created returned as L<DateTime> object. | ||
| 107 | Value is auto-set on insert. | ||
| 108 | |||
| 109 | =cut | ||
| 110 | |||
| 111 | 2 | column created => { | |
| 112 | data_type => "datetime", | ||
| 113 | set_on_create => 1, | ||
| 114 | }; | ||
| 115 | |||
| 116 | =head2 last_modified | ||
| 117 | |||
| 118 | Date and time when this record was last modified returned as L<DateTime> object. | ||
| 119 | Value is auto-set on insert and update | ||
| 120 | |||
| 121 | =cut | ||
| 122 | |||
| 123 | 2 | column last_modified => { | |
| 124 | data_type => "datetime", | ||
| 125 | set_on_create => 1, | ||
| 126 | set_on_update => 1, | ||
| 127 | }; | ||
| 128 | |||
| 129 | =head1 RELATIONS | ||
| 130 | |||
| 131 | =head2 cart | ||
| 132 | |||
| 133 | Type: belongs_to | ||
| 134 | |||
| 135 | Related object: L<Interchange6::Schema::Result::Cart> | ||
| 136 | |||
| 137 | =cut | ||
| 138 | |||
| 139 | 2 | belongs_to | |
| 140 | cart => "Interchange6::Schema::Result::Cart", | ||
| 141 | { carts_id => "carts_id" }, | ||
| 142 | { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }; | ||
| 143 | |||
| 144 | =head2 product | ||
| 145 | |||
| 146 | Type: belongs_to | ||
| 147 | |||
| 148 | Related object: L<Interchange6::Schema::Result::Product> | ||
| 149 | |||
| 150 | =cut | ||
| 151 | |||
| 152 | 2 | belongs_to | |
| 153 | product => "Interchange6::Schema::Result::Product", | ||
| 154 | { sku => "sku" }, | ||
| 155 | { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }; | ||
| 156 | |||
| 157 | 2 | 1; | |