diff options
Diffstat (limited to 'perllib/FixMyStreet/DB')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index b35c5fd0c..b4e42b456 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -296,4 +296,27 @@ sub hide { return $ret; } +sub as_hashref { + my ($self, $c, $cols) = @_; + + my $out = { + id => $self->id, + problem_id => $self->problem_id, + text => $self->text, + state => $self->state, + created => $self->created, + }; + + $out->{problem_state} = $self->problem_state_processed; + + $out->{photos} = [ map { $_->{url} } @{$self->photos} ] if !$cols || $cols->{photos}; + + if ($self->confirmed) { + $out->{confirmed} = $self->confirmed if !$cols || $cols->{confirmed}; + $out->{confirmed_pp} = $c->cobrand->prettify_dt( $self->confirmed ) if !$cols || $cols->{confirmed_pp}; + } + + return $out; +} + 1; |