escolalms / templates-pdf
Escola Headless LMS Templates for pdf
Installs: 8 005
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:package
Requires
- php: >=7.4
- escolalms/core: ^1.2.2
- escolalms/templates: ^0.2.36
- laravel/framework: >=8.0
Requires (Dev)
- escolalms/auth: ^0.1.54
- escolalms/cart: ^0
- escolalms/courses: ^0.3.8
- escolalms/settings: ^0.1.2
- escolalms/topic-types: ^0.2.5
- orchestra/testbench: ^5.0|^6.0
- phpunit/phpunit: ^9.0
Suggests
- escolalms/auth: ^0.1.54
- escolalms/courses: ^0.3.8
- escolalms/settings: ^0.1.2
- dev-main
- 0.1.24
- 0.1.23
- 0.1.22
- 0.1.21
- 0.1.20
- 0.1.19
- 0.1.18
- 0.1.17
- 0.1.16
- 0.1.15
- 0.1.14
- 0.1.13
- 0.1.12
- 0.1.11
- 0.1.10
- 0.1.9
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- 0.0.81
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-feature/readme
- dev-feature/global-settings
- dev-feature/add-title-to-pdfs
- dev-feature/default-template-for-course-certificate-and-seeder
This package is auto-updated.
Last update: 2024-11-22 10:33:06 UTC
README
Package for generating PDFs from configurable Templates.
Purpose
This package allows you to create PDFs generated after a specific Event is emitted in Laravel / LMS app.
Each PDF Template has a corresponding class describing available variables that can be used in the Template (which will be stored in database and editable through admin panel). Templates are saved as serialized fabric.js canvas containing these variables which will be replaced during PDF generation with correct data extracted from Event.
Class describing Template Variables must be registered using Template facade from EscolaLms\Template
package, where you specify which Event it is associated with it and which Channel it is sent through (e.g. EscolaLms\TemplatesPdf\Core\PdfChannel
which is defined in this package).
Installing
composer require escolalms/templates-pdf
php artisan db:migrate
php artisan db:seed --class="EscolaLms\TemplatesPdf\Database\Seeders\TemplatesPdfSeeder"
to create default templates for all Variable/Event pairs registered for PDF channel
Dependencies
EscolaLms\Templates
core Templates package- optional:
EscolaLms\Courses
for generating PDFs related to Courses
Usage
Defining Templates
- Create Event which triggers generation of PDF using specified template. This event must implement method
getUser()
returning User model from LMS Core package. - Create class defining template Variables, which you will use in PDF template,
- Associate your class describing template Variables with correct Event and Channel. Use
EscolaLms\Templates\Facades\Template::register(Event class, EscolaLms\TemplatesPdf\Core\PdfChannel::class, Variable class);
method. - Use admin panel or
/api/admin/templates
web API to create/edit templates associated with this Variable/Event/Channel set. See Template package for more information.
Tests
Run ./vendor/bin/phpunit --filter 'EscolaLms\\TemplatesPdf\\Tests'
to run tests. See tests folder as it contains a basic implementation of Variables class (description of what Template can/must contain) with minimal customisation - a quite good starting point for creating your own.
Usage on front end
Admin panel
Left menu
List of templates
Creating/editing template
Permissions
Permissions are defined in Enum and seeded in Seeder.
Roadmap. Todo. Troubleshooting
- ???