Interchange6-Schema
view release on metacpan or search on metacpan
lib/Interchange6/Schema/Result/Media.pm view on Meta::CPAN
=cut
column priority => { data_type => "integer", default_value => 0 };
=head1 UNIQUE CONSTRAINTS
=head2 C<media_id_media_types_id_unique>
=over 4
=item * L</media_id>
=item * L</media_types_id>
=back
=cut
unique_constraint media_id_media_types_id_unique =>
[ "media_id", "media_types_id" ];
=head1 RELATIONS
=head2 author
Type: belongs_to
Related object: L<Interchange6::Schema::Result::User>
=cut
belongs_to
author => "Interchange6::Schema::Result::User",
{ "foreign.users_id" => "self.author_users_id" },
{ join_type => "left" };
=head2 media_type
Type: belongs_to
Related object: L<Interchange6::Schema::Result::MediaType>
=cut
belongs_to
media_type => "Interchange6::Schema::Result::MediaType",
"media_types_id",
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" };
=head2 media_products
Type: has_many
Related object: L<Interchange6::Schema::Result::MediaProduct>
=cut
has_many
media_products => "Interchange6::Schema::Result::MediaProduct",
"media_id",
{ cascade_copy => 0, cascade_delete => 0 };
=head2 media_navigations
Type: has_many
Related object: L<Interchange6::Schema::Result::MediaNavigation>
=cut
has_many
media_navigations => "Interchange6::Schema::Result::MediaNavigation",
"media_id",
{ cascade_copy => 0, cascade_delete => 0 };
=head2 media_messages
Type: has_many
Related object: L<Interchange6::Schema::Result::MediaMessage>
=cut
has_many
media_messages => "Interchange6::Schema::Result::MediaMessage",
"media_id",
{ cascade_copy => 0, cascade_delete => 0 };
=head2 products
Type: many_to_many with product.
=cut
many_to_many products => "media_products", "product";
=head2 displays
Type: many_to_many with media_displays
=cut
many_to_many displays => "media_type", "media_displays";
=head1 METHODS
=head2 type
Return the media type looking into MediaDisplay and MediaType.
=cut
sub type {
my $self = shift;
# here we return just the first result. UNCLEAR if more are
# needed, but has many... Either we
return $self->media_type->type;
}
=head2 display_uris
Return an hashref with the media display type and the final uri.
=cut
sub display_uris {
my $self = shift;
my %uris;
foreach my $d ( $self->displays ) {
my $path = $d->path;
$path =~ s!/$!!; # remove eventual trailing slash
$uris{ $d->type } = $path . '/' . $self->uri;
}
return \%uris;
}
=head2 display_uri('display_type')
Return the uri for the display type (or undef if not found).
=cut
sub display_uri {
my ( $self, $type ) = @_;
return $self->display_uris->{$type};
}
( run in 1.002 second using v1.01-cache-2.11-cpan-39bf76dae61 )