DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to block abusive or spam text in Laravel form submissions with Laya PHP

Add a validation rule that asks a yes/no question about each submitted text and rejects the bad ones.

Short answer: Run composer require marcreichel/laya-php in your Laravel app; then start laya-serve with docker compose up -d --wait from a clone of this repo and confirm it with php artisan laya:health; add Decides::not('Does the text contain insults, hate speech or threats?') to the rule list for the text field in your $request->validate() call. All steps.

Who it is forA Laravel developer who accepts reviews, comments or messages from users and wants a moderation check on the server.

The problemFree-text fields let in insults, spam and threats, and reviewing every submission by hand does not scale.

The outcomeForm submissions that answer yes to the moderation question fail validation with a friendly message, and the others pass.

What you need first

  • PHP 8.4+ and Composer
  • A PSR-18 HTTP client such as Guzzle or Symfony HttpClient
  • Docker, to run laya-serve from the repo's compose.yaml
  • Laravel 13+ for the Laravel steps (service provider, artisan commands, validation rule, cast)

Steps

  1. Run composer require marcreichel/laya-php in your Laravel app.
  2. Start laya-serve with docker compose up -d --wait from a clone of this repo and confirm it with php artisan laya:health.
  3. Add Decides::not('Does the text contain insults, hate speech or threats?') to the rule list for the text field in your $request->validate() call.
  4. Set your own validation.laya message if the default one does not fit your app.
  5. Test the form with Laya::fake(['answer' => true]) so the rule fails without a running server. (inferred, check the README)

Prompt for your agent

In the marcreichel/laya-php repo's Laravel setup, add a Decides::not rule with the question <moderation question> to the <form field> validation in <controller or form request>. Report which test inputs pass and fail, and verify that a request with a fake answer of true is rejected.

Caveat. If laya-serve is unreachable or busy, the rule fails validation unless you add passWhenUnavailable(), so plan for that case.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for marcreichel/laya-php and "Block abusive or spam text in Laravel form submissions"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer