Laravel AppServiceProvider and Statamic

I have the following code in my AppServiceProvider boot() function:

if (! app()->runningInConsole()) {
    view()->composer('*', function ($view) {
        $user = request()->user();
        $subscribed = false;
        $trialDays = 7;

        if ($user) {

            $trialDays = Carbon::now()->diffInDays($user->created_at->addDays(7));

            $view->with([
                'folders' => $user->folders,
                'subscribed' => $subscribed,
                'trialDays' => $trialDays
            ]);
        }
    });
}

When I access my Statamic CP I don't want this code to run. Currently, it throws an error because $user exists in the Statamic view, but not the created_at and other relations. How can I check if the current view belongs to Statamic?

>>>>>>> Unanswered <<<<<<<
4 Replies
3 Followers