tu6ge / voyager-excel
voyager excel export hook
Installs: 3 463
Dependents: 0
Suggesters: 0
Security: 0
Stars: 21
Watchers: 2
Forks: 11
Open Issues: 1
Requires
- maatwebsite/excel: ^3.1
Requires (Dev)
- laravel/browser-kit-testing: >=5.0
- orchestra/testbench-browser-kit: >=4.0
- phpunit/phpunit: >=8.0
- tcg/voyager: ^1.4
This package is auto-updated.
Last update: 2024-10-29 06:12:50 UTC
README
Voyager Excel Export
a plugin of voyager for excel export
Required
- voyager this is a missing laravel admin
Install
composer require tu6ge/voyager-excel
Usage
1. disable special Model
You can disable export button in special Model :
class Example extends Model
{
public $disable_export = true;
// ...
}
2. Allow export all records of special Model, default export selected records
class Example extends Model
{
public $allow_export_all = true;
// ...
}
3. Custom export excel content and format.
Now, You can customize the export excel content and format, Use more features of maatwebsite/excel
:
- Create a custom export class , and extends
Tu6ge\VoyagerExcel\Exports\AbstractExport
:
<?php
namespace YourApp;
use Tu6ge\VoyagerExcel\Exports\AbstractExport;
class MyCustomExport extends AbstractExport
{
protected $dataType;
protected $model;
public function __construct($dataType, array $ids)
{
$this->dataType = $dataType;
$this->model = new $dataType->model_name(); // this is current Model instance
// $ids is user selected record ids
// write your own idea
}
}
Export
class more usage, see laravel excel documents
- Associate the export with your model:
<?php
namespace Models;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
public $export_handler = \YourApp\MyCustomExport::class;
}
now, you export this Model data , the excel format is your custom.
Support Language
- zh_CN
- en
Test
run composer test
command.
License
Links
Star
If this packages helped you, leave a star for the author.