We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| @@ 51-85 (lines=35) @@ | ||
| 48 | ||
| 49 | } |
|
| 50 | ||
| 51 | public function update($id, Request $request) |
|
| 52 | { |
|
| 53 | $comment = Comment::find($id); |
|
| 54 | ||
| 55 | $user = JWTAuth::parseToken()->authenticate(); |
|
| 56 | ||
| 57 | if ($user->id !== $comment->user_id) { |
|
| 58 | return response()->json( |
|
| 59 | [ |
|
| 60 | 'status_code' => 401, |
|
| 61 | 'message' => 'You haven\'t permission to update this entry' |
|
| 62 | ], 401 |
|
| 63 | ); |
|
| 64 | } |
|
| 65 | ||
| 66 | $comment->comment = $request[ 'comment' ]; |
|
| 67 | ||
| 68 | if (!$comment) { |
|
| 69 | return response()->json( |
|
| 70 | [ |
|
| 71 | 'error_code' => 404, |
|
| 72 | 'error_message' => 'Comment not found!' |
|
| 73 | ], 404 |
|
| 74 | ); |
|
| 75 | } |
|
| 76 | ||
| 77 | $comment->save(); |
|
| 78 | ||
| 79 | return response()->json( |
|
| 80 | [ |
|
| 81 | 'status_code' => 200, |
|
| 82 | 'message' => 'Comment updated!' |
|
| 83 | ], 200 |
|
| 84 | ); |
|
| 85 | } |
|
| 86 | ||
| 87 | public function destroy($id) |
|
| 88 | { |
|
| @@ 87-120 (lines=34) @@ | ||
| 84 | ); |
|
| 85 | } |
|
| 86 | ||
| 87 | public function destroy($id) |
|
| 88 | { |
|
| 89 | $comment = Comment::find($id); |
|
| 90 | ||
| 91 | $user = JWTAuth::parseToken()->authenticate(); |
|
| 92 | ||
| 93 | if ($user->id !== $comment->user_id) { |
|
| 94 | return response()->json( |
|
| 95 | [ |
|
| 96 | 'status_code' => 401, |
|
| 97 | 'message' => 'You haven\'t permission to update this entry' |
|
| 98 | ], 401 |
|
| 99 | ); |
|
| 100 | } |
|
| 101 | ||
| 102 | // Notify error in not found |
|
| 103 | if (!$comment) { |
|
| 104 | return response()->json( |
|
| 105 | [ |
|
| 106 | 'error_code' => 404, |
|
| 107 | 'message' => 'Comment not found!' |
|
| 108 | ], 404 |
|
| 109 | ); |
|
| 110 | } |
|
| 111 | ||
| 112 | $Comment->delete(); |
|
| 113 | ||
| 114 | return response()->json( |
|
| 115 | [ |
|
| 116 | 'status_code' => 204, |
|
| 117 | 'message' => 'Comment deleted' |
|
| 118 | ], 204 |
|
| 119 | ); |
|
| 120 | } |
|
| 121 | } |
|
| 122 | ||