| 1 | 2 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | |||
| 3 | package Interchange6::Schema::Result::Inventory; | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | Interchange6::Schema::Result::Inventory | ||
| 8 | |||
| 9 | =cut | ||
| 10 | |||
| 11 | 2 | ▶ | use Interchange6::Schema::Candy; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | =head1 DESCRIPTION | ||
| 14 | |||
| 15 | The Inventory class is used to store current stock levels for products. | ||
| 16 | |||
| 17 | =head1 ACCESSORS | ||
| 18 | |||
| 19 | =head2 sku | ||
| 20 | |||
| 21 | The SKU of the product. | ||
| 22 | |||
| 23 | Primary key and foreign constraint on | ||
| 24 | L<Interchange6::Schema::Result::Product/sku> via L</product> relationship. | ||
| 25 | |||
| 26 | =cut | ||
| 27 | |||
| 28 | 2 | primary_column sku => | |
| 29 | { data_type => "varchar", is_foreign_key => 1, size => 64 }; | ||
| 30 | |||
| 31 | =head2 quantity | ||
| 32 | |||
| 33 | This is the quantity currently held in stock. | ||
| 34 | |||
| 35 | Defaults to 0. | ||
| 36 | |||
| 37 | =cut | ||
| 38 | |||
| 39 | 2 | column quantity => { data_type => "integer", default_value => 0 }; | |
| 40 | |||
| 41 | =head1 RELATIONS | ||
| 42 | |||
| 43 | =head2 product | ||
| 44 | |||
| 45 | Type: belongs_to | ||
| 46 | |||
| 47 | Related object: L<Interchange6::Schema::Result::Product> | ||
| 48 | |||
| 49 | =cut | ||
| 50 | |||
| 51 | 2 | belongs_to | |
| 52 | product => "Interchange6::Schema::Result::Product", | ||
| 53 | "sku", | ||
| 54 | { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }; | ||
| 55 | |||
| 56 | 2 | 1; | |