maskow/livewire-combined-request
Laravel FormRequest base class that works in HTTP controllers, APIs, and Livewire 3/4 components. Write validation rules, authorization, required parameters, and file upload handling once, then reuse them everywhere. Zero configuration, Laravel 10/11/12 ready.
FormRequest (or trait) that most Laravel teams end up writing themselves once they have both a JSON API and a Livewire UI. The in-house equivalent is small but non-trivial (parameter resolution, auth callback plumbing, camelCase mapping, file upload handling), so this is a genuine make-or-buy call rather than a feature request.Gate/can checks are duplicated between controllers and Livewire components. That duplication is a recurring defect source: a rule tightened in the API drifts from the form. Adopting this package collapses two implementations into one, which directly reduces bug surface and QA matrix size.notifyAuthorizationUsing hook gives a single, controllable UX for authorization failures in Livewire contexts (toasts, flashes, dispatched events). That is a UX decision point — how permission errors present — that would otherwise be ad hoc per component.Adopt when:
rules() array copy-pasted, or authorization checks re-implemented in save() methods.prepareForValidation, withValidator, passedValidation, messages, attributes) to keep working identically in both contexts — this is a meaningful fidelity signal, not just rule sharing.Look elsewhere or build in-house when:
FormRequest suffices.FormRequest hierarchy. The required mixin pattern may conflict with existing base classes.validateLivewire static method is on the order of a few hundred lines. If the team has spare capacity and wants full ownership, that is a defensible alternative.For executives / leadership: We are duplicating validation and permission logic across our API and our Livewire UI, which means the same rule can be enforced in one place and forgotten in another. This package lets us define rules and authorization once and reuse them in both contexts. It is Apache-2.0, zero-configuration, and per-class adoptable, so the downside is bounded: we can pilot it on a couple of forms and remove it without rework. The main caveat is maturity — it is a very small, single-maintainer open-source project, so we should pin the version and treat an internal fork as the fallback. Net: lower defect rate and cheaper dual-surface delivery for a low, reversible dependency cost.
For engineering: A CombinedFormRequest base class that behaves like a normal Laravel FormRequest in controllers and exposes validateLivewire($component, $params) for components. It handles route model binding in HTTP and explicit parameter injection in Livewire through a unified parameter() accessor, throws descriptive exceptions on missing required parameters, and preserves all standard hooks. Optional camelCase↔snake_case conversion is off by default; an authorization-failure callback lets us centralize the error UX. Risk profile: near-zero integration cost, but we own the fork if the package stalls — so pin the version, keep request classes thin, and avoid depending on the optional conversion features until they have proven stable in our codebase.
How can I help you explore Laravel packages today?