Conditions | 8 |
Paths | 17 |
Total Lines | 30 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | */ |
||
23 | public static function findPreviousPost(DiscussPost $post, bool $withSolved = false): ?DiscussPost |
||
24 | { |
||
25 | $previousPost = DiscussPost::where('id', '!=', $post->getKey()) |
||
26 | ->where('conversation_id', $post->conversation->getKey()) |
||
27 | ->where('created_at', '<=', $post->created_at); |
||
28 | |||
29 | if (!$withSolved) { |
||
30 | $previousPost = $previousPost->where('id', '!=', $post->conversation->solved_post_id); |
||
31 | } |
||
32 | |||
33 | return $previousPost->orderBy('created_at', 'desc') |
||
34 | ->first(); |
||
35 | } |
||
36 | } |
||
37 |