Interchange6::Schema::Base::Attribute
The Attribute base class is consumed by classes with attribute relationships like Interchange6::Schema::Result::User, Interchange6::Schema::Result::Navigation and Interchange6::Schema::Result::Product.
This module assumes that your using standardized class naming.
example: User in this example is the $base class so UserAttribute, UserAttributeValue class naming would be used. These would also use user_attributes_id and user_attributes_values_id as primary keys. In general follow the example classes listed in description.
$navigation_object->add_attribute('meta_title','My very seductive title here!');
Add attribute.
$base->add_attribute('hair_color', 'blond');
Where 'hair_color' is Attribute and 'blond' is AttributeValue
Update base attribute value
$base->update_attribute('hair_color', 'brown');
Delete $base attribute
$base->delete_attribute('hair_color', 'purple');
Returns attributes resultset for a $base object
$rs = $base->search_attributes;
You can pass conditions and attributes to the search like for any DBIx::Class::ResultSet, e.g.:
$rs = $base->search_attributes( undef, { order_by => 'priority desc' });
Finds the attribute value for the current object or a defined object value. If $object is passed the entire attribute_value object will be returned. $args can accept both scalar and hash inputs.
$base->find_attribute_value({name => $attr_name, priority => $attr_priority}, {object => 1});
Where $cond and %attrs are passed to the Attribute search and %av_attrs is passed to the AttributeValue search.
my $product = $schema->resultset('Product')->find({ sku = '123' }); my $av = $product->search_attribute_values( undef, { order_by => 'priority' }, { order_by => 'priority' });
Find or create attribute and attribute_value.
From a $base->attribute input $base_attribute, $base_attribute_value is returned.
To install Interchange6::Schema, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Interchange6::Schema
CPAN shell
perl -MCPAN -e shell install Interchange6::Schema
For more information on module installation, please visit the detailed CPAN module installation guide.