Skip to content
PromptPilot AI

Library / Coding & Technology / Refactoring

Laravel: move validation into a Form Request

Thin controllers with proper authorisation.

Cursor / coding agentsClaude CodeChatGPTClaudelaravel
Who it's for
Developers using AI coding tools
Use case
Refactoring
Output
Agent task · Free
You'll need to fill in
Controller@method
Prevents: Validation duplicated across controllers and authorize() left returning true.
Move the validation in [Controller@method] into a dedicated Form Request.
- Generate it with php artisan make:request.
- Implement authorize() using the existing Policy/Gate (do not just return true unless there is truly no auth requirement; tell me if so).
- Keep the exact same rules and messages.
- Use $request->validated() in the controller.
- Add feature tests for one valid and two invalid payloads.

Copies your prompt and opens the official site in a new tab. You may need to paste it yourself (Ctrl/⌘ + V). Nothing is sent to the AI by us.

Replace [bracketed] parts with your own details before sending. Want it tailored? Build a custom website & app development prompt.

Before vs after

A typical one-line request compared with this prompt. We only show sample responses where we've written an illustration.

BeforeWhat people usually type

Prompt

refactoring

1 words · no role, context, format or constraints

AfterThis library prompt

Prompt

Move the validation in [Controller@method] into a dedicated Form Request.
- Generate it with php artisan make:request.
- Implement authorize() using the existing Policy/Gate (do not just return true unless there is truly no auth requirement; tell me if so).
- Keep the exact same rules and messages.
- Use $request->validated() in the controller.
- Add feature tests for one valid and two invalid payloads.

65 words · generated instantly from templates, no AI called

What we added

  • Your details: [brackets] for the facts only you know
  • Constraints: rules and limits

Related prompts