Build a Laravel Lead Form: A Beginner’s Guide for Business Sites
Build a simple Laravel lead form that validates inquiries, stores them safely, and gives your business a clear starting point for lead follow-up.
A Laravel lead form can collect potential customer details, validate submissions, and save them to a database without building a full CRM. This beginner-friendly example shows how to create a simple contact form that is safer and easier to manage than a plain email link.
- Use a database migration to define what lead details you store.
- Validate every submission on the server before saving it.
- Keep the form, route, and controller responsibilities clear.
- Protect customer information and test the whole flow before launch.
Why build a Laravel lead form?
A website lead form gives visitors a clear way to ask about your services. It also creates a consistent record of each inquiry, so your team can follow up instead of relying on a crowded inbox.
For a small business site, start with only the fields you need: name, email, service interest, and message. Avoid collecting sensitive details unless your business has a clear reason and a safe process for handling them.
This tutorial focuses on the basic flow: display a form, receive the request, check the data, and store a lead. For a broader API project, see Building a Simple RESTful API Using Laravel. If you need a tailored system with lead routing or staff dashboards, explore custom web application development.

Prepare your Laravel project and database
Use an existing Laravel project or create one using the installation instructions for the version you have selected. Laravel releases can change, so check the official Laravel documentation for the correct setup steps and commands.
Before creating a table, configure your database connection in the project’s environment file. Use credentials for a development database, and do not commit secret values to a public repository. Then run a migration to confirm that the connection works.
A migration is a version-controlled description of a database change. It lets you build and update tables in a repeatable way, rather than making hidden changes by hand.
Create a migration for leads with Artisan:
php artisan make:model Lead -mOpen the generated migration and define only the fields the form needs. For example, include a name, email address, optional service, message, and timestamps. Choose suitable field types and lengths for your database, and make fields nullable only when the form allows them to be blank.
Schema::create('leads', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email');
$table->string('service')->nullable();
$table->text('message');
$table->timestamps();
});Run the migration with php artisan migrate. If you need to adjust the table later, create another migration rather than editing a migration that has already been applied in a shared environment.
Create a model and a clear route
The model represents a lead in your application. Open the generated app/Models/Lead.php file and define which submitted fields can be assigned together. This is called mass assignment. Restricting the allowed fields helps prevent unexpected request data from being saved.
protected $fillable = [
'name',
'email',
'service',
'message',
];Next, add one route to show the form and another to accept its submission. Keep the route names descriptive so that your Blade template can refer to them reliably.
use App\Http\Controllers\LeadController;
use Illuminate\Support\Facades\Route;
Route::get('/contact', [LeadController::class, 'create'])
->name('leads.create');
Route::post('/contact', [LeadController::class, 'store'])
->name('leads.store');For an existing business website, check whether a contact route already exists before adding another. A clean route structure makes future changes easier and avoids conflicting URLs.

Build the form and validate every field
Create a controller with php artisan make:controller LeadController. Its create method can return a Blade view, while its store method handles a submitted request.
In the view, use a POST form and include Laravel’s CSRF token directive. CSRF protection helps prevent another site from silently submitting a form on a visitor’s behalf.
<form method="POST" action="{{ route('leads.store') }}">
@csrf
<label for="name">Name</label>
<input id="name" name="name" value="{{ old('name') }}" required>
<label for="email">Email</label>
<input id="email" name="email" type="email" value="{{ old('email') }}" required>
<label for="service">Service</label>
<input id="service" name="service" value="{{ old('service') }}">
<label for="message">Message</label>
<textarea id="message" name="message" required>{{ old('message') }}</textarea>
<button type="submit">Send inquiry</button>
</form>Client-side attributes like required help visitors, but they are not security checks. A visitor can bypass browser checks, so validate the request on the server too. Laravel’s official validation documentation explains available rules and error handling.
In the controller, validate input before saving it:
public function store(Request $request)
{
$validated = $request->validate([
'name' => ['required', 'string', 'max:120'],
'email' => ['required', 'email', 'max:255'],
'service' => ['nullable', 'string', 'max:120'],
'message' => ['required', 'string', 'max:5000'],
]);
Lead::create($validated);
return redirect()
->route('leads.create')
->with('success', 'Thanks. Your inquiry has been received.');
}Validation checks that submitted values match the rules before they reach the database. Laravel redirects back with errors for a standard browser form, allowing you to show helpful messages and repopulate valid old input.
Save inquiries and show useful feedback
After validation, Lead::create($validated) stores only the fields that passed your rules and are allowed by the model. Do not save the entire request with $request->all(). That can include fields your application did not intend to accept.
Display success and validation messages in the Blade view. Escape output with Blade’s normal escaped syntax, such as {{ $message }}. Avoid rendering visitor-submitted content as raw HTML.
Make the next step clear after submission. A short confirmation can explain when the visitor should expect a reply, but do not promise a response time your business cannot meet. You may later add an email notification or a staff dashboard, but first make sure saving and error handling work reliably.
For more advanced lead workflows, such as assigning inquiries to staff or connecting to another system, consider a dedicated Laravel development solution. For a complete site that supports lead generation, see website design and development.
Test the lead form before launch
Test the form as a visitor, not just as the developer. Submit a valid inquiry and confirm that it appears in the database. Then try missing fields, a malformed email address, and a message that exceeds your limit.
- Confirm the form loads at the intended URL.
- Check that invalid input produces readable errors.
- Check that valid input is saved once, not twice.
- Verify the success message and follow-up process.
- Test on a phone and with keyboard navigation.
Also review your production settings before launch. Use HTTPS, keep debug output disabled in production, and limit database access to what the application needs. If the form attracts spam, add a measured anti-spam step, such as a honeypot field or a trusted challenge service, while keeping the experience accessible.
Think about access to stored inquiries as well. Restrict database and dashboard access to authorized staff, set a sensible retention policy, and avoid placing personal data in application logs. A simple lead form still handles customer information, so treat it with care.
Frequently asked questions
Is a Laravel lead form difficult for beginners?
The basic form is manageable if you build it in steps: migration, route, view, validation, and saving. Add email notifications and staff tools only after the core flow works.
Do I need a database to receive leads?
No, but storing inquiries in a database makes them easier to track and review. Choose a storage method that fits your follow-up process and privacy responsibilities.
Is browser-side validation enough?
No. Browser checks improve usability, but they can be bypassed. Always validate submitted data on the server before saving it.
How can I reduce spam submissions?
Start with server-side validation and basic rate limits where appropriate. If spam continues, add an accessible anti-spam measure and monitor its impact on real visitors.
Build a better path from inquiry to customer
A Laravel lead form is a practical first feature for a business website: it collects useful details, checks submissions, and gives your team a record to follow up. Start small, test carefully, and expand only when your business workflow calls for it. Need help building a Laravel website or lead management system? Contact Herby Design to discuss your project.
Need help with your website?
I build fast, SEO-ready websites and web applications.