route(); if (empty($route)) { return; } /** @var Invoices|Bills|PortalInvoices $controller */ $controller = $route->getController(); $type = $controller->type ?? ''; if (! Str::contains($type, 'recurring')) { return; } $view->with([ 'type' => $type, ]); // Override the whole file $view->setPath(view('components.documents.form.recurring_metadata', compact('type'))->getPath()); } }