Conditions | 2 |
Paths | 2 |
Total Lines | 24 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | 4 | public function createTipComment($request, $user) |
|
16 | { |
||
17 | 4 | TechTipComments::create([ |
|
18 | 4 | 'tip_id' => $request->tip_id, |
|
19 | 4 | 'user_id' => $user->user_id, |
|
20 | 4 | 'comment' => $request->comment, |
|
21 | ]); |
||
22 | |||
23 | // Notify the tip owner and others who have commented or updated the Tech Tip |
||
24 | 4 | $owners = TechTips::select(['user_id', 'updated_id'])->where('tip_id', $request->tip_id)->first(); |
|
25 | 4 | $others = TechTipComments::select('user_id')->where('tip_id', $request->tip_id)->get(); |
|
26 | |||
27 | $userList = [ |
||
28 | 4 | User::find($owners->user_id), |
|
|
|||
29 | 4 | User::find($owners->updated_id), |
|
30 | ]; |
||
31 | 4 | foreach($others as $o) |
|
32 | { |
||
33 | 4 | $userList[] = User::find($o->user_id); |
|
34 | } |
||
35 | |||
36 | 4 | Notification::send($userList, new NewTechTipCommentNotification($user->full_name, $request->tip_id)); |
|
37 | |||
38 | 4 | return true; |
|
39 | } |
||
47 |