Dealing with Form Spam in Laravel

If you have forms on your site -- contact form, registration form -- you will likely deal with robots generating form spam

You will need to deply technigues to deal with it.

Two techniques are



composer require spatie/laravel-honeypot
php artisan vendor:publish --provider="Spatie\Honeypot\HoneypotServiceProvider" --tag=honeypot-config

Update routes/web.php and add the middleware to all POST routes for form action.

use App\Http\Controllers\ContactController;

use Spatie\Honeypot\ProtectAgainstSpam;

Route::get('contact', [ContactController::class, 'page'])->name('');
Route::post('contact', [ContactController::class, 'send'])->middleware(ProtectAgainstSpam::class)->name('');

Add the honeypot blade directive to any form you need to protect