public function comment(Requests\CommentRequest $request, $slug) { $post = Post::where('slug', $slug)->first(); $akismet = new Akismet(); $akismet->setApiKey(env('AKISMET_KEY', ''))->setBlogUrl('http://rhofma.de')->setCommentAuthor($request['name'])->setCommentAuthorEmail($request['email'])->setCommentContent($request['comment']); if (!empty($request['url'])) { $akismet->setCommentAuthorUrl($request['url']); } if ($akismet->isSpam()) { return back()->with('message', 'FU SPAMMER!'); } Comment::create(['name' => $request['name'], 'email' => $request['email'], 'comment' => $request['comment'], 'url' => $request['url'], 'post_id' => $post->id]); return back()->with('message', 'Danke für das Kommentar :)'); }
/** * @expectedException \nickurt\Akismet\Exception\MalformedURLException */ public function testAkismetInvalidCommentAuthorInformation() { $akismet = new Akismet(); $akismet->setCommentAuthorUrl('foobar'); }