Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added events, validationrule, laravel 5.5+ support only
- Loading branch information
Showing
9 changed files
with
164 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace nickurt\Akismet\Events; | ||
|
||
class IsSpam | ||
{ | ||
/** | ||
* @var | ||
*/ | ||
public $email; | ||
|
||
/** | ||
* IsSpam constructor. | ||
* @param $email | ||
*/ | ||
public function __construct($email) | ||
{ | ||
$this->email = $email; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace nickurt\Akismet\Events; | ||
|
||
class ReportHam | ||
{ | ||
/** | ||
* @var | ||
*/ | ||
public $email; | ||
|
||
/** | ||
* ReportHam constructor. | ||
* @param $email | ||
*/ | ||
public function __construct($email) | ||
{ | ||
$this->email = $email; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace nickurt\Akismet\Events; | ||
|
||
class ReportSpam | ||
{ | ||
/** | ||
* @var | ||
*/ | ||
public $email; | ||
|
||
/** | ||
* ReportSpam constructor. | ||
* @param $email | ||
*/ | ||
public function __construct($email) | ||
{ | ||
$this->email = $email; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
return [ | ||
'it_is_currently_not_possible_to_register_with_your_specified_information_please_try_later_again' => 'It is currently not possible to register with your specified information, please try later again' | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
return [ | ||
'it_is_currently_not_possible_to_register_with_your_specified_information_please_try_later_again' => 'Het is op dit moment niet mogelijk om te registreren met de door u opgegeven informatie, probeer het later opnieuw' | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace nickurt\Akismet\Rules; | ||
|
||
use Illuminate\Contracts\Validation\Rule; | ||
|
||
class AkismetRule implements Rule | ||
{ | ||
/** | ||
* @var | ||
*/ | ||
protected $email; | ||
|
||
/** | ||
* @var | ||
*/ | ||
protected $author; | ||
|
||
/** | ||
* Create a new rule instance. | ||
* | ||
* @param $email | ||
* @param $author | ||
* | ||
* @return void | ||
*/ | ||
public function __construct($email, $author) | ||
{ | ||
$this->email = $email; | ||
$this->author = $author; | ||
} | ||
|
||
/** | ||
* Determine if the validation rule passes. | ||
* | ||
* @param string $attribute | ||
* @param mixed $value | ||
* @return bool | ||
*/ | ||
public function passes($attribute, $value) | ||
{ | ||
$akismet = akismet(); | ||
|
||
if ($akismet->validateKey()) { | ||
$akismet->setCommentAuthor($this->author) | ||
->setCommentAuthorEmail($this->email) | ||
->setCommentType('registration'); | ||
|
||
return $akismet->isSpam() ? false : true; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation error message. | ||
* | ||
* @return string | ||
*/ | ||
public function message() | ||
{ | ||
return trans('akismet::akismet.it_is_currently_not_possible_to_register_with_your_specified_information_please_try_later_again'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters