@@ -61,22 +61,22 @@ |
||
| 61 | 61 | |
| 62 | 62 | // Post to Slack. |
| 63 | 63 | if ($slackPostUrl = getenv('SLACK_WEBHOOK_URL')) { |
| 64 | - $commentLink = sprintf("<https://%s/%s|%s>", getenv('BASEURL'), $commentData['slug'], $commentData['slug']); |
|
| 65 | - $deleteUrl = sprintf("/api/comments/delete/%s/%s", $commentData['id'], urlencode($commentData['token'])); |
|
| 66 | - $requestParameters = array( |
|
| 64 | + $commentLink = sprintf("<https://%s/%s|%s>", getenv('BASEURL'), $commentData['slug'], $commentData['slug']); |
|
| 65 | + $deleteUrl = sprintf("/api/comments/delete/%s/%s", $commentData['id'], urlencode($commentData['token'])); |
|
| 66 | + $requestParameters = array( |
|
| 67 | 67 | 'text' => sprintf("New comment from %s on post %s:\n\n%s\n\nTo delete, use %s", |
| 68 | - $commentData['name'], |
|
| 69 | - $commentLink, |
|
| 70 | - $commentData['comment'], |
|
| 71 | - $deleteUrl |
|
| 68 | + $commentData['name'], |
|
| 69 | + $commentLink, |
|
| 70 | + $commentData['comment'], |
|
| 71 | + $deleteUrl |
|
| 72 | 72 | ), |
| 73 | 73 | 'username' => 'Squabble', |
| 74 | - ); |
|
| 74 | + ); |
|
| 75 | 75 | |
| 76 | - $client = new Client(); |
|
| 77 | - $client->request('POST', $slackPostUrl, [ |
|
| 76 | + $client = new Client(); |
|
| 77 | + $client->request('POST', $slackPostUrl, [ |
|
| 78 | 78 | 'body' => json_encode($requestParameters), |
| 79 | - ]); |
|
| 79 | + ]); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | return CommentHelpers::formatData(array($commentData)); |
@@ -7,14 +7,14 @@ discard block |
||
| 7 | 7 | use App\Helpers\CommentHelpers; |
| 8 | 8 | use GuzzleHttp\Client; |
| 9 | 9 | |
| 10 | -class CommentController extends Controller{ |
|
| 10 | +class CommentController extends Controller { |
|
| 11 | 11 | |
| 12 | 12 | public function index() { |
| 13 | 13 | $comments = Comment::all(); |
| 14 | 14 | return ($comments) ? CommentHelpers::formatData($comments) : CommentHelpers::formatData(array(), FALSE); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - public function getComment($id){ |
|
| 17 | + public function getComment($id) { |
|
| 18 | 18 | $comment = Comment::find($id); |
| 19 | 19 | return ($comment) ? CommentHelpers::formatData(array($comment)) : CommentHelpers::formatData(array(), FALSE); |
| 20 | 20 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | return ($comments) ? CommentHelpers::formatData($comments) : CommentHelpers::formatData(array(), FALSE); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function saveComment(Request $request){ |
|
| 39 | + public function saveComment(Request $request) { |
|
| 40 | 40 | $commentData = array( |
| 41 | 41 | 'name' => $request->input('name'), |
| 42 | 42 | 'email' => $request->input('email'), |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | 'ip' => $request->getClientIp(), |
| 46 | 46 | ); |
| 47 | 47 | |
| 48 | - $commentData['token'] = md5(\Hash::make($commentData['comment'] . $commentData['email'] . $commentData['slug'])); |
|
| 48 | + $commentData['token'] = md5(\Hash::make($commentData['comment'].$commentData['email'].$commentData['slug'])); |
|
| 49 | 49 | $comment = Comment::create($commentData); |
| 50 | 50 | |
| 51 | 51 | $commentData['created_at'] = $comment->created_at->toDateTimeString(); |