Kritim Yantra
Jul 03, 2025
You just landed your first freelance web project. You’re excited, ready to code, and then comes the client’s final request:
“Can you also add an invoicing and billing feature to the system?”
Wait—what? 😳
You nod confidently... but in your head, you're already Googling "how to build an invoice system in Laravel." Sound familiar?
If that scenario rings a bell, you’re in the right place.
In this post, we’ll break down how to build a simple yet powerful Invoice & Billing Management System using Laravel 12 — step by step, no experience required.
Whether you're building a SaaS app, running an e-commerce platform, or freelancing, billing is non-negotiable. And Laravel 12, with its latest features and enhancements, makes it easier than ever to handle invoices, track payments, and send professional billing documents — all without reinventing the wheel.
By the end of this tutorial, you'll know how to:
✅ Set up an invoice system from scratch
✅ Manage customers and their bills
✅ Generate PDFs for invoices
✅ Send invoice emails like a pro
Let’s roll up our sleeves! 🛠️
Here’s what your Laravel Invoice System will include:
First things first — let’s install Laravel 12.
composer create-project laravel/laravel invoice-system
cd invoice-system
php artisan serve
Open your browser and go to http://localhost:8000
Boom! You’ve got Laravel up and running 🚀
You’ll need three main tables:
Let’s generate these:
php artisan make:model Customer -m
php artisan make:model Invoice -m
php artisan make:model InvoiceItem -m
Schema::create('customers', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email');
$table->string('address')->nullable();
$table->timestamps();
});
Run the migrations:
php artisan migrate
We’ll now connect everything using Eloquent relationships.
Customer.php
public function invoices() {
return $this->hasMany(Invoice::class);
}
Invoice.php
public function customer() {
return $this->belongsTo(Customer::class);
}
public function items() {
return $this->hasMany(InvoiceItem::class);
}
InvoiceItem.php
public function invoice() {
return $this->belongsTo(Invoice::class);
}
Eloquent makes relationship handling super intuitive — it’s like magic but with code!
Let’s make a form to create a new invoice.
Your form might include:
Here’s a simplified controller method:
public function store(Request $request)
{
$invoice = Invoice::create([
'customer_id' => $request->customer_id,
'invoice_date' => $request->invoice_date,
'status' => 'unpaid'
]);
foreach ($request->items as $item) {
InvoiceItem::create([
'invoice_id' => $invoice->id,
'description' => $item['description'],
'quantity' => $item['quantity'],
'price' => $item['price']
]);
}
return redirect()->route('invoices.index')->with('success', 'Invoice Created!');
}
✅ Easy to follow
✅ Keeps things modular
✅ Totally beginner-friendly
Install barryvdh/laravel-dompdf — a fantastic PDF package.
composer require barryvdh/laravel-dompdf
Then in your controller:
use PDF;
public function download($id) {
$invoice = Invoice::with('items', 'customer')->findOrFail($id);
$pdf = PDF::loadView('invoices.pdf', compact('invoice'));
return $pdf->download('invoice-'.$invoice->id.'.pdf');
}
🎉 Now your users can download pro-looking invoices with one click.
Laravel makes email a breeze.
Mail::to($invoice->customer->email)->send(new InvoiceMail($invoice));
Make sure to create a Mailable
:
php artisan make:mail InvoiceMail --markdown=emails.invoice
Then add the logic in your InvoiceMail
class to attach the PDF.
You can use a simple dropdown or toggle in your UI to mark invoices as:
In the invoices
table, just add a status
column and use Laravel’s forms to update it.
Don’t forget to wrap your invoice routes in auth
middleware:
Route::middleware(['auth'])->group(function () {
Route::resource('invoices', InvoiceController::class);
});
✅ Keeps data secure
✅ Prevents unauthorized access
Let’s recap what you’ve just accomplished:
That’s a full billing system right there. And it’s just the beginning.
Happy Coding! ❤️
You’re not just learning Laravel — you’re building real-world solutions.
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google