Skip to content
Discussion options

You must be logged in to vote

To do things only during Nova requests, you can use \Laravel\Nova\Nova::whenServing().
The first argument can be used to do things during Nova requests, and the second argument would be when it's not a Nova request (i.e., should be frontend for non-Nova routes, Artisan commands, etc).

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\App;
use Laravel\Nova\Nova;

// Can be done in NovaServiceProvider, AppServiceProvider, or wherever you'd like.
// (As long as it's not too early/late in the process)
Nova::whenServing(
    function (): void {
        Model::preventLazyLoading(false);
    },
    function (): void {
        Model::preventLazyLoading(App::isLocal());
    },…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@StanBarrows
Comment options

Answer selected by StanBarrows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants