DEV Community

Cover image for I Built a Laravel Approval Engine to Stop Email Spam šŸš€
Apurba Singh
Apurba Singh

Posted on

I Built a Laravel Approval Engine to Stop Email Spam šŸš€

Over the last few months, while working on enterprise Laravel projects, I noticed a recurring "Notification Nightmare."

Every company needs an approval workflow (requisitions, invoices, PTO), but most systems flood managers with separate notifications for every single item.

I decided to build a solution: Laravel Approval Engine.


šŸ”„ The "Smart Batching" Concept

The core problem with enterprise workflows isn't the approval logic; it's notification fatigue. Instead of sending 50 separate emails for 50 pending approvals, my engine buffers them into 1 smart batch. The manager receives a single, clean digest with secure, token-based links to approve everything at once.

šŸ—ļø How it Works

The architecture is designed to be modular and plug-and-play.

  1. Define a Module: Use php artisan make:workflow-module to create a logic class.
  2. Queue Records: Your business models enter a "pending" state.
  3. The Processor: A scheduled artisan command bundles pending records into a Batch.
  4. Action: The approver receives a single email. They can Approve All, Reject, or View Details via a secure Next.js dashboard.

🧠 Technical Highlights

  • Multi-stage Workflows: Easily route from Manager -> Finance -> CEO.
  • Token-based Security: Approvers don't even need to log in to take action.
  • Event-Driven: Hooks for every stage (Created, Approved, Escalated).
  • Next.js Dashboard: A sleek frontend for managing the workflow status.
  • Laravel 12 Ready: Built to work with the latest PHP 8.2+ features.

šŸ“Š The Workflow Flow

graph TD
    A[Pending Records] --> B[Smart Batch Created]
    B --> C[Email Digest Sent]
    C --> D[Approver Clicks Link]
    D --> E[Stage Resolver]
    E --> F{Next Stage?}
    F -- Yes --> G[Create Next Batch]
    F -- No --> H[Workflow Completed]
Enter fullscreen mode Exit fullscreen mode

šŸš€ Try the Demo

I've included a demo inside the repo so you can see it in action in under 2 minutes:

git clone https://github.com/apurba-labs/laravel-approval-engine
cd laravel-approval-engine/example/laravel-demo
composer install
php artisan approval:demo
Enter fullscreen mode Exit fullscreen mode

šŸ”— GitHub

I’d love for the community to check it out, give it a star, or suggest new features!

šŸ‘‰ Get the Code on GitHub


Would love to hear your feedback! How do you handle complex approval routing in your own Laravel apps?

Top comments (0)