Package Data | |
---|---|
Maintainer Username: | nickurt |
Package Create Date: | 2015-05-27 |
Package Last Update: | 2024-11-09 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-17 03:00:31 |
Package Statistics | |
---|---|
Total Downloads: | 101,284 |
Monthly Downloads: | 1,106 |
Daily Downloads: | 2 |
Total Stars: | 91 |
Total Watchers: | 3 |
Total Forks: | 12 |
Total Open Issues: | 1 |
Install this package with composer:
composer require nickurt/laravel-akismet
Add the provider to config/app.php file
'nickurt\Akismet\ServiceProvider',
and the facade in the file
'Akismet' => 'nickurt\Akismet\Facade',
Copy the config files for the api
php artisan vendor:publish --provider="nickurt\Akismet\ServiceProvider" --tag="config"
The Akismet information can be set with environment values in the .env file (or directly in the config/akismet.php file)
AKISMET_APIKEY=MY_UNIQUE_APIKEY
AKISMET_BLOGURL=https://my-custom-blogurl.dev
You can use a hidden-field akismet
in your Form-Request to validate if the request is valid
$validator = validator()->make(['akismet' => 'akismet'], ['akismet' => [new \nickurt\Akismet\Rules\AkismetRule(
request()->input('email'), request()->input('name')
)]]);
The AkismetRule
requires a email
and name
parameter to validate the request.
You can listen to the IsSpam
, ReportSpam
and ReportHam
events, e.g. if you want to log all the IsSpam
-requests in your application
This event will be fired when the request contains spam
nickurt\Akismet\Events\IsSpam
This event will be fired when you succesfully reported spam
nickurt\Akismet\Events\ReportSpam
This event will be fired when you succesfully reported ham
nickurt\Akismet\Events\ReportHam
if( \Akismet::validateKey() ) {
// valid
} else {
// invalid
}
\Akismet::setCommentAuthor("John Doe")
->setCommentAuthorUrl("https://www.google.com")
->setCommentContent("It's me, John!")
->setCommentType('registration');
// etc
// or
\Akismet::setCommentAuthor("John Doe");
\Akismet::setCommentAuthorUrl("https://www.google.com");
\Akismet::setCommentContent("It's me, John!");
// etc
if( \Akismet::getCommentAuthor() == 'John Doe' ) {
// it's me John!
}
if( \Akismet::isSpam() ) {
// yes, i'm spam!
}
if( \Akismet::reportSpam() ) {
// yes, thanks!
}
if( \Akismet::reportHam() ) {
// yes, thanks!
}
phpunit