Download the PHP package syspons/laravel-sheetable without Composer
On this page you can find all versions of the php package syspons/laravel-sheetable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-sheetable
Laravel-Sheetable
A helper for importing and exporting Eloquent models.
Easily add import + export routes + controllers by adding a Trait to your model.
This package utilizes laravel-excel which is a wrapper around PhpSpreadsheet
Installation
Concept
The package provides an interface to the database using excel import and export. It can be used to create or update entities, not to delete them. For updating a unique identifier in the table is necessary.
Dropdownable
Plain data from the table will be shown in the export as is. However, there might be relations within the data, that shall be shown inside the export (or import).
These are defined by DropdownConfig
s. These represent a relation within the excel. It is possible to include one to many and many to many relationships.
For every relation you'll find a dropdown in your excel to select one of the related entities.
There will be a workbook inside your spreadsheet that contains all related models, mapped to their key, in order to make it possible to import these relations as well.
Join
If you want more, than a single column of a relation joined to your export table, you will need to use the Join
functionality. You have the possibility to add nested joins and to select any column of the joined table.
Usage
- Create your table and corresponding model, eg. with
php artisan make:model YourModel -m
- Implement the
Sheetable
interface in your newly generated model. - The package will register the following routes:
- Export, get, post
yourmodels/export
=> export all desired entities - Template, get
yourmodels/template
=> export an empty spreadsheet - Import, post
yourmodels/import
=> import a spreadsheet
- Export, get, post
Options
To change the default options use
- Inherited from laravel-targetable
namespace
: String or array with one ore multiple namespaces that should be monitored for the configured trait. Defaults toApp\Models
.namespace_mode
: Defines the search mode for the namespaces.ClassFinder::STANDARD_MODE
will only find the exact matching namespace,ClassFinder::RECURSIVE_MODE
will find all subnamespaces. Defaults toClassFinder::STANDARD_MODE
.prefix
: Defines the route prefix. Defaults toapi
.
- Formats
export_format
: Defines the export format. Possible values are:XLSX
,CSV
,TSV
,ODS
,XLS
,HTML
,MPDF
,DOMPDF
,TCPDF
. See the Laravel-Excel Documentation. Defaults toXLSX
.import_format
: Defines the import format. Possible values are:XLSX
,CSV
,TSV
,ODS
,XLS
,SLK
,XML
,GNUMERIC
,HTML
. See the Laravel-Excel Documentation. Defaults toANY
.
Architecture
- The package relies on laravel-targetable to connect specific functionality to Laravel model entities via contracts. (
Sheetable
,Dropdownable
). - The entrypoints to all functionality is provided by the
SheetController
by utilizinglaravel-excel
.SheetsExport
is used to provide export + template functionality.SheetImport
is used to provide import functionality.- Both rely on
SpreadsheetHelper
andSpreadsheetUtils
for core functionality.
ExportRequest
implements the rules for selecting entities or columns to export- The
SpreadsheetDropdowns
helper implements all functionality connected to relations /Dropdownable
s. SpreadsheetJoins
andJoin
gather the join functionality.
Compatibility
Tested with Laravel 10.x.
License
See License File. Copyright © 2023 Jan Bladt.
All versions of laravel-sheetable with dependencies
haydenpierce/class-finder Version ^0.4.3
barryvdh/laravel-ide-helper Version 2.12.3
maatwebsite/excel Version ^3.0