a plugin of voyager for excel export
composer require tu6ge/voyager-excel
You can disable export button in special Model :
class Example extends Model
{
public $disable_export = true;
// ...
}
class Example extends Model
{
public $allow_export_all = true;
// ...
}
Now, You can customize the export excel content and format, Use more features of maatwebsite/excel
:
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
<?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.
run composer test
command.
If this packages helped you, leave a star for the author.