| 1 | use utf8; | ||
| 2 | package Rapi::Blog::DB::Result::Tag; | ||
| 3 | |||
| 4 | # Created by DBIx::Class::Schema::Loader | ||
| 5 | # DO NOT MODIFY THE FIRST PART OF THIS FILE | ||
| 6 | |||
| 7 | use strict; | ||
| 8 | use warnings; | ||
| 9 | |||
| 10 | use Moose; | ||
| 11 | use MooseX::NonMoose; | ||
| 12 | use MooseX::MarkAsMethods autoclean => 1; | ||
| 13 | extends 'DBIx::Class::Core'; | ||
| 14 | __PACKAGE__->load_components("InflateColumn::DateTime"); | ||
| 15 | __PACKAGE__->table("tag"); | ||
| 16 | __PACKAGE__->add_columns( | ||
| 17 | "name", | ||
| 18 | { data_type => "varchar", is_nullable => 0, size => 64 }, | ||
| 19 | ); | ||
| 20 | __PACKAGE__->set_primary_key("name"); | ||
| 21 | __PACKAGE__->has_many( | ||
| 22 | "post_tags", | ||
| 23 | "Rapi::Blog::DB::Result::PostTag", | ||
| 24 | { "foreign.tag_name" => "self.name" }, | ||
| 25 | { cascade_copy => 0, cascade_delete => 0 }, | ||
| 26 | ); | ||
| 27 | |||
| 28 | |||
| 29 | # Created by DBIx::Class::Schema::Loader v0.07045 @ 2017-05-26 13:35:23 | ||
| 30 | # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:C93siCyHQ1D1co2F2bqQhg | ||
| 31 | |||
| 32 | use RapidApp::Util ':all'; | ||
| 33 | |||
| 34 | __PACKAGE__->load_components('+Rapi::Blog::DB::Component::SafeResult'); | ||
| 35 | |||
| 36 | sub posts_count { | ||
| 37 | my $self = shift; | ||
| 38 | # In case the ResultSet has pre-loaded this value, don't do another query: | ||
| 39 | my $preload = try{$self->get_column('posts_count')}; | ||
| 40 | defined $preload ? $preload : $self->post_tags->count | ||
| 41 | } | ||
| 42 | |||
| 43 | |||
| 44 | # You can replace this text with custom code or comments, and it will be preserved on regeneration | ||
| 45 | __PACKAGE__->meta->make_immutable; | ||
| 46 | 1; |