inertiajs / inertia-laravel

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

Exclude `except` props from partial reloads #622

Closed lepikhinb closed 1 month ago

lepikhinb commented 2 months ago

The PR introduces an ability to exclude properties from partial responses. The except option can be used together with only to refine nested props.

The corresponding client-side PR: https://github.com/inertiajs/inertia/pull/1876

router.visit(url, {
  only: ['auth'],
  except: ['auth.user'],
})
$props = [
    // Included on partial reload
    'auth' => [
        // Excluded from partial reload
        'user' => new LazyProp(function () {
            return [
                'name' => 'Jonathan Reinink',
                'email' => 'jonathan@example.com',
            ];
        }),
        // Included on partial reload
        'refresh_token' => 'value',
    ],
    // Excluded from partial reload
    'shared' => [
        'flash' => 'value',
    ],
];
driesvints commented 2 months ago

Please make sure to mark this as ready for review if you need one.

lepikhinb commented 2 months ago

@driesvints just want to get the client PR ready first