1use utf8; 2 3package Interchange6::Schema::ResultSet::Navigation; 4 5=head1 NAME 6 7Interchange6::Schema::ResultSet::Navigation 8 9=cut 10 11=head1 SYNOPSIS 12 13Provides extra accessor methods for L<Interchange6::Schema::Result::Navigation> 14 15=cut 16 17use strict; 18use warnings; 19use mro 'c3'; 20 21use parent 'Interchange6::Schema::ResultSet'; 22 23=head1 METHODS 24 25=head2 active 26 27Returns all rows where L<Interchange6::Schema::Result::Navigation/active> is 28true. 29 30=cut 31 32sub active { 33 return $_[0]->search( { $_[0]->me('active') => 1 } ); 34} 35 36=head2 with_active_child_count 37 38Create slot C<active_child_count> in the resultset containing the count of 39active child navs. 40 41=cut 42 43sub with_active_child_count { 44 my $self = shift; 45 46 return $self->search( 47 undef, 48 { 49 '+columns' => { 50 active_child_count => 51 $self->correlate('active_children')->count_rs->as_query 52 }, 53 } 54 ); 55} 56 57=head2 with_active_product_count 58 59Create slot C<active_product_count> in the resultset containing the count of 60active products associated with each navigation row. 61 62=cut 63 64sub with_active_product_count { 65 my $self = shift; 66 67 return $self->search( 68 undef, 69 { 70 '+columns' => { 71 active_product_count => 72 $self->correlate('navigation_products') 73 ->related_resultset('product')->active->count_rs->as_query 74 }, 75 } 76 ); 77} 78 791; 80