inertiajs / inertia-laravel

The Laravel adapter for Inertia.js.
https://inertiajs.com
MIT License
2.01k stars 224 forks source link

Add dinamic parameters to Inertia::lazyLoad props #570

Closed sot1986 closed 4 months ago

sot1986 commented 8 months ago

Most of the times that I am reaching for lazyLoading props, I would really appreciate to have the possibility to pass some parameters to the callback. I would propose something like:

router.visit(url, { only: ['user:10'] })

On the backed I would handle like

public function __invoke(Request $request)
{  
  return Inertia::render('Users/Page', [  
  'users' => fn () => Users::query()->cursorPaginate(),  
  'user' => Inertia::lazy(fn (User $user) => $user  
  ];  
}

Make sense?

driesvints commented 4 months ago

Heya, thanks for your proposal. Feel free to attempt a PR so the maintainers can look at actual code that's involved. Thanks