lepikhinb / momentum-modal

MIT License
442 stars 26 forks source link

add option to force base url #43

Closed emargareten closed 1 year ago

emargareten commented 1 year ago

Currently the baseUrl option is only working as a fallback option i.e. when the modal url is accessed directly from the browser's address bar.

This PR adds an option to force the base page to render even if the request is an inertia request (my use case is for a page that is protected by the auth middleware but the modal is not).

Usage:

return Inertia::modal('Tweets/Show')
            ->baseRoute('tweets.index')
            ->forceBase();

// or pass in a boolean

$shouldForce = request()->header('referer') !== 'https://example.com/tweets/create';

return Inertia::modal('Tweets/Show')
            ->baseRoute('tweets.index')
            ->forceBase($shouldForce);
what-the-diff[bot] commented 1 year ago