diff options
author | Zarino Zappia <mail@zarino.co.uk> | 2019-08-22 10:55:20 +0100 |
---|---|---|
committer | Zarino Zappia <mail@zarino.co.uk> | 2019-08-23 10:38:29 +0100 |
commit | 3c73315e3b6a9d403b008bb06a6497224f2486c4 (patch) | |
tree | c477c26e2602c97c156bc154e85a67f1d47dbbd6 /perllib/FixMyStreet/DB/Result/User.pm | |
parent | 3c4d48f5fd5f499736f07ac2a5d17c1d4bab6c14 (diff) |
$user->latest_visible_problem() convenience method
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/User.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/User.pm | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm index 4ea7524bb..51f959e0e 100644 --- a/perllib/FixMyStreet/DB/Result/User.pm +++ b/perllib/FixMyStreet/DB/Result/User.pm @@ -198,6 +198,15 @@ sub latest_anonymity { return $obj ? $obj->anonymous : 0; } +sub latest_visible_problem { + my $self = shift; + return $self->problems->search({ + state => [ FixMyStreet::DB::Result::Problem->visible_states() ] + }, { + order_by => { -desc => 'id' } + })->single; +} + =head2 check_for_errors $error_hashref = $user->check_for_errors(); |