Skip to content

API reference / Quittio \ Laravel \ Templates

BladeTemplateEngine

final class in quittio/laravel · implements TemplateEngine

Quittio\Laravel\Templates\BladeTemplateEngine · Source

Renders Blade views with the invoice view model as $invoice. The name "default" maps to the configured template. Template names may come from invoice data, so only these views can be selected: the configured template (quittio.pdf.template), the shipped views under "quittio::templates." (no partials) and the views of quittio.pdf.templates ("invoices.*" or "namespace::*" allows every view below a prefix). Names that are no Blade view fall back to the plain PHP templates, which resolve names inside their template directories only (never file paths).

Methods#

MethodDescription
->__construct()
->allows()
::fromSettings()The engine of the configuration: pdf.template for "default" and the views of pdf.templates (a missing key means ['invoices.*'], the views of make:quittio-template). Rendering and the preview use it, so both accept the same views.
->render()

__construct()#

public function __construct(
    Factory $views,
    string $defaultView = 'quittio::templates.default.layout',
    PhpTemplateEngine $fallback = new \Quittio\Core\Templates\PhpTemplateEngine(),
    list<string> $allowed = [],
)
ParameterTypeDescription
$viewsIlluminate\Contracts\View\Factory
$defaultViewstring = 'quittio::templates.default.layout'
$fallbackPhpTemplateEngine = new \Quittio\Core\Templates\PhpTemplateEngine()
$allowedlist<string> = []further selectable views or "prefix*" patterns

allows()#

public function allows(string $view): bool
ParameterTypeDescription
$viewstring
Returns
bool

fromSettings()#

public static function fromSettings(Factory $views, Settings $settings): self

static

The engine of the configuration: pdf.template for "default" and the views of pdf.templates (a missing key means ['invoices.*'], the views of make:quittio-template). Rendering and the preview use it, so both accept the same views.

ParameterTypeDescription
$viewsIlluminate\Contracts\View\Factory
$settingsSettings
Returns
self

render()#

public function render(
    string $template,
    InvoiceViewModel $invoice,
    array $data = [],
): string
ParameterTypeDescription
$templatestring
$invoiceInvoiceViewModel
$dataarray = []
Returns
string

The open core packages are MIT licensed. The legal wording of the country packs must be confirmed by a tax adviser.