support the new inertia once props feature. (Inertia::once) #1147
isaackearl
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
The Inertia integration in laravel-data is very good (thank you). Lazy::inertia() and Lazy::closure() cover most use cases well. However, Inertia v2 recently introduced https://inertiajs.com/partial-reloads#once-props (Inertia::once) which are resolved on the first visit, cached client-side, and excluded from subsequent responses (including redirects). There's currently no way to express this behavior inside a laravel-data DTO.
The Gap
already has.
back()->withErrors()) because it's excluded from full visits.
behavior, but can only be used at the controller level — not inside a DTO.
Use Case
Lookup data for forms (dropdowns that rarely change etc) is a good example. It's static during a session,
expensive to query, and needed across form submissions. Currently you either:
encapsulation
Proposal
A Lazy::once() (or similar) that tells Inertia this prop should behave as a once prop — resolved on the first
visit and cached client-side:
class CaseShowResponse extends Data
{
public function __construct(
public int $id,
/** @var Lazy|DataCollection<int, EventTypeResponse> */
public Lazy|DataCollection $eventTypes,
) {}
}
Beta Was this translation helpful? Give feedback.
All reactions