Файловый менеджер - Редактировать - /home/easybachat/hisabat365.com/4a7891/laravel-datatables-export.tar
Ðазад
phpstan.neon.dist 0000644 00000000526 15060247610 0010050 0 ustar 00 includes: - ./vendor/larastan/larastan/extension.neon parameters: paths: - src level: max ignoreErrors: - '#Parameter \#1 \$callback of method Illuminate\\Container\\Container::call\(\) expects \(callable\(\): mixed\)\|string*#' excludePaths: - tests checkMissingIterableValueType: false src/WithExportQueue.php 0000644 00000002345 15060247610 0011173 0 ustar 00 <?php namespace Yajra\DataTables; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Bus; use Yajra\DataTables\Jobs\DataTableExportJob; /** * @mixin \Yajra\DataTables\Services\DataTable */ trait WithExportQueue { /** * Process dataTables needed render output. * * @return mixed * * @throws \Throwable */ public function render(?string $view = null, array $data = [], array $mergeData = []) { if (request()->ajax() && request('action') == 'exportQueue') { return $this->exportQueue(); } return parent::render($view, $data, $mergeData); } /** * Create and run batch job. * * * @throws \Throwable */ public function exportQueue(): string { $job = new DataTableExportJob( [self::class, $this->attributes], request()->all(), Auth::id() ?? 0, $this->sheetName(), ); $batch = Bus::batch([$job])->name('datatables-export')->dispatch(); return $batch->id; } /** * Default sheet name. * Character limit 31. */ protected function sheetName(): string { return request('sheetName', 'Sheet1'); } } src/Livewire/ExportButtonComponent.php 0000644 00000006153 15060247610 0014200 0 ustar 00 <?php namespace Yajra\DataTables\Livewire; use Illuminate\Bus\Batch; use Illuminate\Contracts\Support\Renderable; use Illuminate\Support\Facades\Bus; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use Livewire\Component; use Symfony\Component\HttpFoundation\StreamedResponse; /** * @property Batch $exportBatch */ class ExportButtonComponent extends Component { public string $class = 'btn btn-primary'; public ?string $tableId = null; public ?string $emailTo = ''; public string $type = 'xlsx'; public string $filename = ''; public string $buttonName = 'Export'; public string $sheetName = 'Sheet1'; public bool $autoDownload = false; public bool $downloaded = false; public bool $exporting = false; public bool $exportFinished = false; public bool $exportFailed = false; public ?string $batchJobId = null; public function export(string $batchJobId): void { $this->batchJobId = $batchJobId; $this->exportFinished = false; $this->exportFailed = false; $this->exporting = true; $this->downloaded = false; } public function getExportBatchProperty(): ?Batch { if (! $this->batchJobId) { return null; } return Bus::findBatch($this->batchJobId); } public function updateExportProgress(): ?StreamedResponse { $this->exportFinished = $this->exportBatch->finished(); $this->exportFailed = $this->exportBatch->hasFailures(); if ($this->exportFinished) { $this->exporting = false; if ($this->autoDownload and ! $this->downloaded) { $this->downloaded = true; return $this->downloadExport(); } } return null; } public function downloadExport(): StreamedResponse { if ($this->getS3Disk()) { return Storage::disk($this->getS3Disk()) ->download($this->batchJobId.'.'.$this->getType(), $this->getFilename()); } return Storage::disk($this->getDisk())->download($this->batchJobId.'.'.$this->getType(), $this->getFilename()); } protected function getType(): string { if (Str::endsWith($this->filename, ['csv', 'xlsx'])) { return pathinfo($this->filename, PATHINFO_EXTENSION); } return $this->type == 'csv' ? 'csv' : 'xlsx'; } protected function getFilename(): string { if (Str::endsWith(Str::lower($this->filename), ['csv', 'xlsx'])) { return $this->filename; } return Str::random().'.'.$this->getType(); } public function render(): Renderable { return view('datatables-export::export-button', [ 'fileType' => $this->getType(), ]); } protected function getDisk(): string { /** @var string $disk */ $disk = config('datatables-export.disk', 'local'); return $disk; } protected function getS3Disk(): string { /** @var string $disk */ $disk = config('datatables-export.s3_disk', ''); return $disk; } } src/Commands/DataTablesPurgeExportCommand.php 0000644 00000002531 15060247610 0015317 0 ustar 00 <?php namespace Yajra\DataTables\Commands; use Illuminate\Console\Command; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; class DataTablesPurgeExportCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'datatables:purge-export'; /** * The console command description. * * @var string */ protected $description = 'Remove exported files that datatables-export generate.'; /** * Execute the console command. * * @return void */ public function handle() { /** @var string $disk */ $disk = config('datatables-export.disk', 'local'); /** @var int $daysOld */ $daysOld = config('datatables-export.purge.days', 1); $timestamp = now()->subDays($daysOld)->getTimestamp(); collect(Storage::disk($disk)->files()) ->each(function ($file) use ($timestamp, $disk) { $path = Storage::disk($disk)->path($file); if (File::lastModified($path) < $timestamp && Str::endsWith(strtolower($file), ['xlsx', 'csv'])) { File::delete($path); } }); $this->info('The command was successful. Export files are cleared!'); } } src/Jobs/DataTableExportJob.php 0000644 00000022427 15060247610 0012427 0 ustar 00 <?php namespace Yajra\DataTables\Jobs; use Carbon\Carbon; use DateTimeInterface; use Illuminate\Auth\Events\Login; use Illuminate\Bus\Batchable; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Http\File; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Arr; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use OpenSpout\Common\Entity\Cell; use OpenSpout\Common\Entity\Row; use OpenSpout\Common\Entity\Style\Style; use OpenSpout\Writer\Common\Creator\WriterFactory; use OpenSpout\Writer\XLSX\Helper\DateHelper; use OpenSpout\Writer\XLSX\Writer as XLSXWriter; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use Yajra\DataTables\Html\Column; use Yajra\DataTables\Services\DataTable; class DataTableExportJob implements ShouldBeUnique, ShouldQueue { use Batchable; use Dispatchable; use InteractsWithQueue; use Queueable; use SerializesModels; /** * @var class-string<DataTable> */ public string $dataTable; public array $attributes = []; /** * @param array{class-string<DataTable>, array} $instance */ public function __construct( array $instance, public array $request, public int|string|null $user, public string $sheetName = 'Sheet1' ) { $this->dataTable = $instance[0]; $this->attributes = $instance[1]; } /** * Execute the job. * * @throws \OpenSpout\Common\Exception\IOException * @throws \OpenSpout\Common\Exception\UnsupportedTypeException * @throws \OpenSpout\Writer\Exception\WriterNotOpenedException * @throws \OpenSpout\Writer\Exception\InvalidSheetNameException */ public function handle(): void { if ($this->user) { Event::forget(Login::class); Auth::loginUsingId($this->user); } /** @var DataTable $oTable */ $oTable = resolve($this->dataTable); request()->merge($this->request); $query = app()->call([$oTable->with($this->attributes), 'query']); /** @var \Yajra\DataTables\QueryDataTable $dataTable */ $dataTable = app()->call([$oTable, 'dataTable'], compact('query')); $dataTable->skipPaging(); $type = 'xlsx'; $exportType = request('export_type', 'xlsx'); if (is_string($exportType)) { $type = Str::of($exportType)->startsWith('csv') ? 'csv' : 'xlsx'; } $filename = $this->batchId.'.'.$type; $path = Storage::disk($this->getDisk())->path($filename); $writer = WriterFactory::createFromFile($filename); $writer->openToFile($path); if ($writer instanceof XLSXWriter) { $sheet = $writer->getCurrentSheet(); $sheet->setName(substr($this->sheetName, 0, 31)); } $columns = $this->getExportableColumns($oTable); $headers = []; $columns->each(function (Column $column) use (&$headers) { $headers[] = strip_tags($column->title); }); $writer->addRow(Row::fromValues($headers)); if ($this->usesLazyMethod()) { $chunkSize = 1_000; if (is_int(config('datatables-export.chunk'))) { $chunkSize = config('datatables-export.chunk'); } $query = $dataTable->getFilteredQuery()->lazy($chunkSize); } else { $query = $dataTable->getFilteredQuery()->cursor(); } foreach ($query as $row) { $cells = []; $row = $row instanceof Arrayable ? $row->toArray() : (array) $row; if ($this->usesLazyMethod() && is_array($row)) { $row = Arr::dot($row); } $defaultDateFormat = 'yyyy-mm-dd'; if (config('datatables-export.default_date_format') && is_string(config('datatables-export.default_date_format')) ) { $defaultDateFormat = config('datatables-export.default_date_format'); } $columns->map(function (Column $column) use ($row, &$cells, $defaultDateFormat) { $property = $column->data; /* Handles orthogonal data */ if (is_array($property)) { $property = $property['_'] ?? $column->name; } /** @var array|bool|int|string|null|DateTimeInterface $value */ $value = $row[$property] ?? ''; if (is_array($value)) { $value = json_encode($value); } switch (true) { case $this->wantsText($column): if ($value instanceof DateTimeInterface) { $cellValue = $value->format($defaultDateFormat); } else { $cellValue = strval($value); } $format = $column->exportFormat ?? '@'; break; case $this->wantsDateFormat($column): if ($value instanceof DateTimeInterface) { $cellValue = DateHelper::toExcel($value); } else { $cellValue = $value ? DateHelper::toExcel(Carbon::parse(strval($value))) : ''; } $format = $column->exportFormat ?? $defaultDateFormat; break; case $this->wantsNumeric($column): if ($value instanceof DateTimeInterface) { $cellValue = 0.0; } else { $cellValue = floatval($value); } $format = $column->exportFormat; break; case $value instanceof DateTimeInterface: $cellValue = $value; $format = $column->exportFormat ?? $defaultDateFormat; break; default: $cellValue = $this->isNumeric($value) ? floatval($value) : $value; $format = $column->exportFormat ?? NumberFormat::FORMAT_GENERAL; } $cells[] = Cell::fromValue($cellValue, (new Style)->setFormat($format)); }); $writer->addRow(new Row($cells)); } $writer->close(); if ($this->getS3Disk()) { Storage::disk($this->getS3Disk())->putFileAs('', (new File($path)), $filename); } $emailTo = request('emailTo'); if ($emailTo && is_string($emailTo)) { $data = ['email' => urldecode($emailTo), 'path' => $path]; $this->sendResults($data); } } protected function getDisk(): string { $disk = 'local'; if (is_string(config('datatables-export.disk'))) { $disk = config('datatables-export.disk'); } return $disk; } /** * @return \Illuminate\Support\Collection<array-key, Column> */ protected function getExportableColumns(DataTable $dataTable): Collection { $columns = $dataTable->html()->getColumns(); return $columns->filter(fn (Column $column) => $column->exportable); } protected function usesLazyMethod(): bool { return config('datatables-export.method', 'lazy') === 'lazy'; } protected function wantsText(Column $column): bool { if (! isset($column['exportFormat'])) { return false; } return in_array($column['exportFormat'], (array) config('datatables-export.text_formats', ['@'])); } protected function wantsDateFormat(Column $column): bool { if (! isset($column['exportFormat'])) { return false; } /** @var array $formats */ $formats = config('datatables-export.date_formats', []); return in_array($column['exportFormat'], $formats); } protected function wantsNumeric(Column $column): bool { return Str::contains($column->exportFormat, ['0', '#']); } /** * @param int|bool|string|null $value */ protected function isNumeric($value): bool { // Skip numeric style if value has leading zeroes. if (Str::startsWith(strval($value), '0')) { return false; } return is_numeric($value); } protected function getS3Disk(): string { $disk = ''; if (config('datatables-export.s3_disk') && is_string(config('datatables-export.s3_disk'))) { $disk = config('datatables-export.s3_disk'); } return $disk; } public function sendResults(array $data): void { Mail::send('datatables-export::export-email', $data, function ($message) use ($data) { $message->attach($data['path']); $message->to($data['email']) ->subject('Export Report'); $message->from(config('datatables-export.mail_from')); }); } } src/resources/views/export-email.blade.php 0000644 00000000051 15060247610 0014664 0 ustar 00 Attached you will find requested report. src/resources/views/export-button.blade.php 0000644 00000004535 15060247610 0015123 0 ustar 00 <div class="d-flex align-items-center" x-data> <form class="mr-2" x-on:submit.prevent=" $refs.exportBtn.disabled = true; var oTable = LaravelDataTables['{{ $tableId }}']; var baseUrl = oTable.ajax.url() === '' ? window.location.toString() : oTable.ajax.url(); var url = new URL(baseUrl); var searchParams = new URLSearchParams(url.search); searchParams.set('action', 'exportQueue'); searchParams.set('exportType', '{{$fileType}}'); searchParams.set('sheetName', '{{$sheetName}}'); searchParams.set('buttonName', '{{$buttonName}}'); searchParams.set('emailTo', '{{urlencode($emailTo)}}'); var tableParams = $.param(oTable.ajax.params()); if (tableParams) { var tableSearchParams = new URLSearchParams(tableParams); tableSearchParams.forEach((value, key) => { searchParams.append(key, value); }); } url.search = searchParams.toString(); $.get(url.toString()).then(function(exportId) { $wire.export(exportId); }).catch(function(error) { $wire.exportFinished = true; $wire.exporting = false; $wire.exportFailed = true; }); " > <button type="submit" x-ref="exportBtn" :disabled="$wire.exporting" class="{{ $class }}" >{{$buttonName}} </button> </form> @if($exporting && $emailTo) <div class="d-inline">Export will be emailed to {{ $emailTo }}.</div> @endif @if($exporting && !$exportFinished) <div class="d-inline" wire:poll="updateExportProgress">Exporting...please wait.</div> @endif @if($exportFinished && !$exportFailed && !$autoDownload) <span>Done. Download file <a href="#" class="text-primary" wire:click.prevent="downloadExport">here</a></span> @endif @if($exportFinished && !$exportFailed && $autoDownload && $downloaded) <span>Done. File has been downloaded.</span> @endif @if($exportFailed) <span>Export failed, please try again later.</span> @endif </div> src/ExportServiceProvider.php 0000644 00000002237 15060247610 0012366 0 ustar 00 <?php namespace Yajra\DataTables; use Illuminate\Support\ServiceProvider; use Livewire\Livewire; use Livewire\LivewireServiceProvider; use Yajra\DataTables\Commands\DataTablesPurgeExportCommand; use Yajra\DataTables\Livewire\ExportButtonComponent; class ExportServiceProvider extends ServiceProvider { public function boot(): void { $this->loadViewsFrom(__DIR__.'/resources/views', 'datatables-export'); $this->publishAssets(); Livewire::component('export-button', ExportButtonComponent::class); } protected function publishAssets(): void { $this->publishes([ __DIR__.'/config/datatables-export.php' => config_path('datatables-export.php'), ], 'datatables-export'); $this->publishes([ __DIR__.'/resources/views' => base_path('/resources/views/vendor/datatables-export'), ], 'datatables-export'); } public function register(): void { $this->mergeConfigFrom(__DIR__.'/config/datatables-export.php', 'datatables-export'); $this->commands([DataTablesPurgeExportCommand::class]); $this->app->register(LivewireServiceProvider::class); } } src/config/datatables-export.php 0000644 00000007522 15060247610 0012743 0 ustar 00 <?php use PhpOffice\PhpSpreadsheet\Style\NumberFormat; return [ /* |-------------------------------------------------------------------------- | Method |-------------------------------------------------------------------------- | | Method to use to iterate with the query results. | Options: lazy, cursor | | @link https://laravel.com/docs/eloquent#cursors | @link https://laravel.com/docs/eloquent#chunking-using-lazy-collections | */ 'method' => 'lazy', /* |-------------------------------------------------------------------------- | Chunk Size |-------------------------------------------------------------------------- | | Chunk size to be used when using lazy method. | */ 'chunk' => 1000, /* |-------------------------------------------------------------------------- | Export filesystem disk |-------------------------------------------------------------------------- | | Export filesystem disk where generated files will be stored. | */ 'disk' => 'local', /* |-------------------------------------------------------------------------- | Use S3 for final file destination |-------------------------------------------------------------------------- | | After generating the file locally, it can be uploaded to s3. | */ 's3_disk' => '', /* |-------------------------------------------------------------------------- | Mail from address |-------------------------------------------------------------------------- | | Will be used to email report from this address. | */ 'mail_from' => env('MAIL_FROM_ADDRESS', ''), /* |-------------------------------------------------------------------------- | Default Date Format |-------------------------------------------------------------------------- | | Default export format for date. | */ 'default_date_format' => 'yyyy-mm-dd', /* |-------------------------------------------------------------------------- | Valid Date Formats |-------------------------------------------------------------------------- | | List of valid date formats to be used for auto-detection. | */ 'date_formats' => [ 'mm/dd/yyyy', NumberFormat::FORMAT_DATE_DATETIME, NumberFormat::FORMAT_DATE_YYYYMMDD, NumberFormat::FORMAT_DATE_XLSX22, NumberFormat::FORMAT_DATE_DDMMYYYY, NumberFormat::FORMAT_DATE_DMMINUS, NumberFormat::FORMAT_DATE_DMYMINUS, NumberFormat::FORMAT_DATE_DMYSLASH, NumberFormat::FORMAT_DATE_MYMINUS, NumberFormat::FORMAT_DATE_TIME1, NumberFormat::FORMAT_DATE_TIME2, NumberFormat::FORMAT_DATE_TIME3, NumberFormat::FORMAT_DATE_TIME4, NumberFormat::FORMAT_DATE_TIME5, NumberFormat::FORMAT_DATE_TIME6, NumberFormat::FORMAT_DATE_TIME7, NumberFormat::FORMAT_DATE_XLSX14, NumberFormat::FORMAT_DATE_XLSX15, NumberFormat::FORMAT_DATE_XLSX16, NumberFormat::FORMAT_DATE_XLSX17, NumberFormat::FORMAT_DATE_YYYYMMDD2, NumberFormat::FORMAT_DATE_YYYYMMDDSLASH, ], /* |-------------------------------------------------------------------------- | Valid Text Formats |-------------------------------------------------------------------------- | | List of valid text formats to be used. | */ 'text_formats' => [ '@', NumberFormat::FORMAT_GENERAL, NumberFormat::FORMAT_TEXT, ], /* |-------------------------------------------------------------------------- | Purge Options |-------------------------------------------------------------------------- | | Purge all exported by purge.days old files. | */ 'purge' => [ 'days' => 1, ], ]; CONTRIBUTING.md 0000644 00000001651 15060247610 0007001 0 ustar 00 # Contributing Contributions are **welcome** and will be fully **credited**. We accept contributions via Pull Requests on [Github](https://github.com/yajra/laravel-datatables-export). ## Pull Requests - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting. **Happy coding**! LICENSE.md 0000644 00000002117 15060247610 0006152 0 ustar 00 (The MIT License) Copyright (c) 2013-2022 Arjay Angeles <aqangeles@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. phpunit.xml.dist 0000644 00000001001 15060247610 0007710 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false"> <testsuites> <testsuite name="Package Test Suite"> <directory suffix="Test.php">./tests/</directory> </testsuite> </testsuites> </phpunit> rector.php 0000644 00000001032 15060247610 0006550 0 ustar 00 <?php declare(strict_types=1); use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\LevelSetList; return static function (RectorConfig $rectorConfig): void { $rectorConfig->paths([ __DIR__.'/src', __DIR__.'/tests', ]); // register a single rule $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); // define sets of rules $rectorConfig->sets([ LevelSetList::UP_TO_PHP_82, ]); }; UPGRADE.md 0000644 00000000376 15060247610 0006164 0 ustar 00 # UPGRADE GUIDE ## Upgrade from 10.x to 11.x 1. Update the composer.json file and change the version of the package to `^11.0`: ```json "require": { "yajra/laravel-datatables-export": "^11.0" } ``` 2. Run `composer update` to update the package. CHANGELOG.md 0000644 00000001067 15060247610 0006362 0 ustar 00 # Laravel DataTables Export Plugin CHANGELOG. ## UNRELEASED ## v11.1.1 - 2024-04-29 - fix: pestphp require-dev #61 - bump deps - fix: yajra/laravel-datatables#3136 ## v11.1.0 - 2024-04-29 - feat: add button name option #59 ## v11.0.1 - 2024-04-16 - fix: Export button URL: Merge new with existing query params #58 - fix #57 - Handle new params with existing query params in the export button URL ## v11.0.0 - 2023-03-14 - Laravel 11.x support - Use Pest for testing - Add Pint and Rector for code quality - Add GitHub Actions for CI/CD - Fix PhpStan issues composer.json 0000644 00000004126 15060247610 0007272 0 ustar 00 { "name": "yajra/laravel-datatables-export", "description": "Laravel DataTables Queued Export Plugin.", "keywords": [ "laravel", "datatables", "export", "excel", "livewire", "queue" ], "license": "MIT", "authors": [ { "name": "Arjay Angeles", "email": "aqangeles@gmail.com" } ], "require": { "php": "^8.2", "ext-json": "*", "livewire/livewire": "^2.11.2|^3.4.12", "openspout/openspout": "^4.24.1", "phpoffice/phpspreadsheet": "^1.29", "yajra/laravel-datatables-buttons": "^11.0" }, "require-dev": { "larastan/larastan": "^2.9.6", "orchestra/testbench": "^9.0.4", "pestphp/pest": "^2.34.7", "pestphp/pest-plugin-laravel": "^2.4", "laravel/pint": "^1.15.3", "rector/rector": "^1.1" }, "autoload": { "psr-4": { "Yajra\\DataTables\\": "src/" } }, "autoload-dev": { "psr-4": { "Yajra\\DataTables\\Exports\\Tests\\": "tests/" } }, "scripts": { "test": "./vendor/bin/pest", "pint": "./vendor/bin/pint", "rector": "./vendor/bin/rector", "stan": "./vendor/bin/phpstan analyse --memory-limit=2G --ansi --no-progress --no-interaction --configuration=phpstan.neon.dist", "pr": [ "@rector", "@pint", "@stan", "@test" ] }, "config": { "preferred-install": "dist", "sort-packages": true, "optimize-autoloader": true, "allow-plugins": { "pestphp/pest-plugin": true } }, "extra": { "branch-alias": { "dev-master": "11.x-dev" }, "laravel": { "providers": [ "Yajra\\DataTables\\ExportServiceProvider" ] } }, "minimum-stability": "dev", "prefer-stable": true, "funding": [ { "type": "github", "url": "https://github.com/sponsors/yajra" } ] } .styleci.yml 0000644 00000000020 15060247610 0007012 0 ustar 00 preset: laravel README.md 0000644 00000016054 15060247610 0006032 0 ustar 00 # Laravel DataTables Export Plugin [](http://laravel.com) [](https://packagist.org/packages/yajra/laravel-datatables-export) [](https://github.com/yajra/laravel-datatables-export/actions/workflows/continuous-integration.yml) [](https://github.com/yajra/laravel-datatables-export/actions/workflows/static-analysis.yml) [](https://packagist.org/packages/yajra/laravel-datatables-export) [](https://packagist.org/packages/yajra/laravel-datatables-export) This package is a plugin of [Laravel DataTables](https://github.com/yajra/laravel-datatables) for handling server-side exporting using Queue, OpenSpout and Livewire. ## Requirements - [PHP >=8.2](http://php.net/) - [Laravel 11](https://github.com/laravel/framework) - [Laravel Livewire](https://laravel-livewire.com/) - [OpenSpout](https://github.com/openspout/openspout/) - [Laravel DataTables 11.x](https://github.com/yajra/laravel-datatables) - [jQuery DataTables v1.10.x](http://datatables.net/) ## Documentations - [Laravel DataTables Documentation](http://yajrabox.com/docs/laravel-datatables) ## Laravel Version Compatibility | Laravel | Package | |:--------|:--------| | 8.x | 0.x | | 9.x | 1.x | | 10.x | 10.x | | 11.x | 11.x | ## Quick Installation `composer require yajra/laravel-datatables-export:^11.0` The package also requires batch job: ```shell php artisan queue:batches-table php artisan migrate ``` #### Service Provider (Optional since Laravel 5.5+) `Yajra\DataTables\ExportServiceProvider::class` #### Configuration and Assets (Optional) `$ php artisan vendor:publish --tag=datatables-export --force` ## Usage 1. Add the export-button livewire component on your view file that uses dataTable class. ```html <livewire:export-button :table-id="$dataTable->getTableId()"/> ``` 2. On your `DataTable` class, use `WithExportQueue` ```php use Yajra\DataTables\WithExportQueue; class PermissionsDataTable extends DataTable { use WithExportQueue; ... } ``` 3. Run your queue worker. Ex: `php artisan queue:work` ## Purging exported files On `app\Console\Kernel.php`, register the purge command ```php $schedule->command('datatables:purge-export')->weekly(); ``` ## Export Filename You can set the export filename by setting the property. ```html <livewire:export-button :table-id="$dataTable->getTableId()" filename="my-table.xlsx"/> <livewire:export-button :table-id="$dataTable->getTableId()" filename="my-table.csv"/> <livewire:export-button :table-id="$dataTable->getTableId()" :filename="$filename"/> ``` ## Export Button Name You can set the export button name by setting the `buttonName` property. ```html <!-- Examples demonstrating how to customize the button name for different scenarios --> <livewire:export-button :table-id="$dataTable->getTableId()" type="xlsx" buttonName="Export Excel"/> <livewire:export-button :table-id="$dataTable->getTableId()" type="csv" buttonName="Export CSV"/> ``` ## Export Type You can set the export type by setting the property to `csv` or `xlsx`. Default value is `xlsx`. ```html <livewire:export-button :table-id="$dataTable->getTableId()" type="xlsx"/> <livewire:export-button :table-id="$dataTable->getTableId()" type="csv"/> ``` ## Set Excel Sheet Name Option 1: You can set the Excel sheet name by setting the property. ```html <livewire:export-button :table-id="$dataTable->getTableId()" sheet-name="Monthly Report"/> ``` Option 2: You can also set the Excel sheet name by overwriting the method. ```php protected function sheetName() : string { return "Yearly Report"; } ``` ## Formatting Columns You can format the column by setting it via Column definition on you DataTable service class. ```php Column::make('mobile')->exportFormat('00000000000'), ``` The format above will treat mobile numbers as text with leading zeroes. ## Numeric Fields Formatting The package will auto-detect numeric fields and can be used with custom formats. ```php Column::make('total')->exportFormat('0.00'), Column::make('count')->exportFormat('#,##0'), Column::make('average')->exportFormat('#,##0.00'), ``` ## Date Fields Formatting The package will auto-detect date fields when used with a valid format or is a DateTime instance. ```php Column::make('report_date')->exportFormat('mm/dd/yyyy'), Column::make('created_at'), Column::make('updated_at')->exportFormat(NumberFormat::FORMAT_DATE_DATETIME), ``` ## Valid Date Formats Valid date formats can be adjusted on `datatables-export.php` config file. ```php 'date_formats' => [ 'mm/dd/yyyy', NumberFormat::FORMAT_DATE_DATETIME, NumberFormat::FORMAT_DATE_YYYYMMDD, NumberFormat::FORMAT_DATE_XLSX22, NumberFormat::FORMAT_DATE_DDMMYYYY, NumberFormat::FORMAT_DATE_DMMINUS, NumberFormat::FORMAT_DATE_DMYMINUS, NumberFormat::FORMAT_DATE_DMYSLASH, NumberFormat::FORMAT_DATE_MYMINUS, NumberFormat::FORMAT_DATE_TIME1, NumberFormat::FORMAT_DATE_TIME2, NumberFormat::FORMAT_DATE_TIME3, NumberFormat::FORMAT_DATE_TIME4, NumberFormat::FORMAT_DATE_TIME5, NumberFormat::FORMAT_DATE_TIME6, NumberFormat::FORMAT_DATE_TIME7, NumberFormat::FORMAT_DATE_XLSX14, NumberFormat::FORMAT_DATE_XLSX15, NumberFormat::FORMAT_DATE_XLSX16, NumberFormat::FORMAT_DATE_XLSX17, NumberFormat::FORMAT_DATE_YYYYMMDD2, NumberFormat::FORMAT_DATE_YYYYMMDDSLASH, ] ``` ## Force Numeric Field As Text Format Option to force auto-detected numeric value as text format. ```php Column::make('id')->exportFormat('@'), Column::make('id')->exportFormat(NumberFormat::FORMAT_GENERAL), Column::make('id')->exportFormat(NumberFormat::FORMAT_TEXT), ``` ## Auto Download Option to automatically download the exported file. ```html <livewire:export-button :table-id="$dataTable->getTableId()" filename="my-table.xlsx" auto-download="true"/> ``` ## Contributing Please see [CONTRIBUTING](https://github.com/yajra/laravel-datatables-export/blob/master/.github/CONTRIBUTING.md) for details. ## Security If you discover any security related issues, please email [aqangeles@gmail.com](mailto:aqangeles@gmail.com) instead of using the issue tracker. ## Credits - [Arjay Angeles](https://github.com/yajra) - [All Contributors](https://github.com/yajra/laravel-datatables-export/graphs/contributors) - [Laravel Daily](https://github.com/LaravelDaily/Laravel-Excel-Export-Import-Large-Files) ## License The MIT License (MIT). Please see [License File](https://github.com/yajra/laravel-datatables-export/blob/master/LICENSE.md) for more information. CONDUCT.md 0000644 00000012243 15060247610 0006170 0 ustar 00 # Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others’ private information, such as a physical or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning Community Impact: A violation through a single incident or series of actions. Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban Community Impact: A serious violation of community standards, including sustained inappropriate behavior. Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. Consequence: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the Contributor Covenant, version 2.1, available at https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines were inspired by Mozilla’s code of conduct enforcement ladder. For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
| ver. 1.4 |
Github
|
.
| PHP 8.2.29 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка