Download the PHP package mnvx/eloquent-print-form without Composer
On this page you can find all versions of the php package mnvx/eloquent-print-form. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package eloquent-print-form
Print forms for Eloquent
Easy way to generate docx print forms of invoices, contracts and other documents.
Usage
Installation
Declare models for Eloquent.
Create print form (docx file) using next syntax.
${field_name}
- standard field${entity.field_name}
- field from linked entity${entity.field_name|date}
- format field as date${entity.field_name|date|placeholder}
- format field as date and replace to "____" if field is empty${entity1.entity2.field_name}
- field from linked entity through one table${entities.field_name}
- for table data
As you may see, it is possible to use pipes, for example: |date
, |date|placeholder
. Supported pipes are:
placeholder
- replaces empty variable to "____".date
- format datedateTime
- format date timeint
- format int valuedecimal
- format decimal value
It is possible also to specify custom pipes.
Generate print form for specified entity
Examples
Basic example
For example, if there are next models in project.
Example of Laravel's controller action for printing contract.
Example of docx template
Contract number: ${number|placeholder}
Contract date: ${start_at|date|placeholder}
Customer: ${customer.name}
Customer category: ${customer.category.name|placeholder}
Appendixes:
Row number | Appendix number | Appendix tax |
---|---|---|
${appendixes.#row_number} | ${appendixes.number} | ${appendixes.tax} |
Example of generated document
Contract number: F-123
Contract date: 12.04.2012
Customer: IBM
Customer category: ____
Appendixes:
Row number | Appendix number | Appendix tax |
---|---|---|
1 | A-1 | 1234 |
2 | A-1.1 | 0 |
3 | B-1 | 10 |
How to specify custom pipes
How to specify custom processors for some variables
Example of custom processor for variable ${custom}
.