Conditions | 5 |
Paths | 12 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | public function deleting(DiscussPost $discussPost): void |
||
27 | { |
||
28 | $conversation = $discussPost->conversation; |
||
29 | |||
30 | if ($conversation->first_post_id == $discussPost->getKey()) { |
||
31 | $conversation->delete(); |
||
32 | } |
||
33 | |||
34 | if ($conversation->last_post_id == $discussPost->getKey()) { |
||
35 | $previousPost = DiscussPostRepository::findPreviousPost($discussPost, true); |
||
36 | |||
37 | $conversation->last_post_id = !is_null($previousPost) ? $previousPost->getKey() : null; |
||
38 | } |
||
39 | |||
40 | if ($conversation->solved_post_id == $discussPost->getKey()) { |
||
41 | $conversation->solved_post_id = null; |
||
42 | $conversation->is_solved = false; |
||
43 | } |
||
44 | |||
45 | $conversation->save(); |
||
46 | } |
||
48 |