Conditions | 4 |
Paths | 6 |
Total Lines | 21 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
34 | public function deleting(DiscussPost $discussPost): void |
||
35 | { |
||
36 | $discussPost->loadMissing('conversation'); |
||
37 | $conversation = $discussPost->conversation; |
||
38 | |||
39 | /*if ($conversation->first_post_id === $discussPost->getKey()) { |
||
40 | $conversation->delete(); |
||
41 | }*/ |
||
42 | |||
43 | if ($conversation->last_post_id === $discussPost->getKey()) { |
||
44 | $previousPost = DiscussPostRepository::findPreviousPost($discussPost, true); |
||
45 | |||
46 | $conversation->last_post_id = !is_null($previousPost) ? $previousPost->getKey() : null; |
||
47 | } |
||
48 | |||
49 | if ($conversation->solved_post_id === $discussPost->getKey()) { |
||
50 | $conversation->solved_post_id = null; |
||
51 | $conversation->is_solved = false; |
||
52 | } |
||
53 | |||
54 | $conversation->save(); |
||
55 | } |
||
57 |