Файловый менеджер - Редактировать - /home/easybachat/hisabat365.com/4a7891/laravel-datatables-buttons.tar
Ðазад
src/Services/DataTablesExportHandler.php 0000644 00000000254 15060250025 0014327 0 ustar 00 <?php namespace Yajra\DataTables\Services; use Yajra\DataTables\Exports\DataTablesCollectionExport; class DataTablesExportHandler extends DataTablesCollectionExport { } src/Services/DataTable.php 0000644 00000044721 15060250025 0011453 0 ustar 00 <?php namespace Yajra\DataTables\Services; use Barryvdh\Snappy\PdfWrapper; use Closure; use Generator; use Illuminate\Contracts\Support\Renderable; use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Relations\Relation as EloquentRelation; use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Http\JsonResponse; use Illuminate\Http\Resources\Json\AnonymousResourceCollection; use Illuminate\Http\Response; use Illuminate\Support\Collection; use Illuminate\Support\LazyCollection; use Maatwebsite\Excel\ExcelServiceProvider; use Rap2hpoutre\FastExcel\FastExcel; use Yajra\DataTables\Contracts\DataTableButtons; use Yajra\DataTables\Contracts\DataTableScope; use Yajra\DataTables\Exceptions\Exception; use Yajra\DataTables\Html\Builder; use Yajra\DataTables\Html\Column; use Yajra\DataTables\QueryDataTable; use Yajra\DataTables\Transformers\DataArrayTransformer; use Yajra\DataTables\Utilities\Request; abstract class DataTable implements DataTableButtons { /** * DataTables print preview view. * * @phpstan-var view-string */ protected string $printPreview = 'datatables::print'; /** * Name of the dataTable variable. */ protected string $dataTableVariable = 'dataTable'; /** * List of columns to be excluded from export. */ protected array $excludeFromExport = []; /** * List of columns to be excluded from printing. */ protected array $excludeFromPrint = []; /** * List of columns to be exported. */ protected string|array $exportColumns = '*'; /** * List of columns to be printed. */ protected string|array $printColumns = '*'; /** * Query scopes. * * @var \Yajra\DataTables\Contracts\DataTableScope[] */ protected array $scopes = []; /** * Html builder. */ protected ?Builder $htmlBuilder = null; /** * Html builder extension callback. * * @var callable|null */ protected $htmlCallback; /** * Export filename. */ protected string $filename = ''; /** * Custom attributes set on the class. */ protected array $attributes = []; /** * Callback before sending the response. * * @var callable|null */ protected $beforeCallback; /** * Callback after processing the response. * * @var callable|null */ protected $responseCallback; /** * Available button actions. When calling an action, the value will be used * as the function name (so it should be available) * If you want to add or disable an action, overload and modify this property. */ protected array $actions = ['print', 'csv', 'excel', 'pdf']; protected ?Request $request = null; /** * Flag to use fast-excel package for export. */ protected bool $fastExcel = false; /** * Flag to enable/disable fast-excel callback. * Note: Disabling this flag can improve you export time. * Enabled by default to emulate the same output * with laravel-excel. */ protected bool $fastExcelCallback = true; /** * Export class handler. * * @var class-string */ protected string $exportClass = DataTablesExportHandler::class; /** * CSV export typewriter. */ protected string $csvWriter = 'Csv'; /** * Excel export typewriter. */ protected string $excelWriter = 'Xlsx'; /** * PDF export typewriter. */ protected string $pdfWriter = 'Dompdf'; public function __construct() { /** @var Request $request */ $request = app('datatables.request'); /** @var Builder $builder */ $builder = app('datatables.html'); $this->request = $request; $this->htmlBuilder = $builder; } /** * Process dataTables needed render output. * * @phpstan-param view-string|null $view * * @return mixed */ public function render(?string $view = null, array $data = [], array $mergeData = []) { if ($this->request()->ajax() && $this->request()->wantsJson()) { return app()->call($this->ajax(...)); } /** @var string $action */ $action = $this->request()->get('action'); $actionMethod = $action === 'print' ? 'printPreview' : $action; if (in_array($action, $this->actions) && method_exists($this, $actionMethod)) { /** @var callable $callback */ $callback = [$this, $actionMethod]; return app()->call($callback); } /** @phpstan-ignore-next-line */ return view($view, $data, $mergeData)->with($this->dataTableVariable, $this->getHtmlBuilder()); } /** * Get DataTables Request instance. */ public function request(): Request { if (! $this->request) { $this->request = app(Request::class); } return $this->request; } /** * Display ajax response. */ public function ajax(): JsonResponse { $query = null; if (method_exists($this, 'query')) { /** @var EloquentBuilder|QueryBuilder|EloquentRelation $query */ $query = app()->call([$this, 'query']); $query = $this->applyScopes($query); } /** @var \Yajra\DataTables\DataTableAbstract $dataTable */ // @phpstan-ignore-next-line $dataTable = app()->call([$this, 'dataTable'], compact('query')); if (is_callable($this->beforeCallback)) { app()->call($this->beforeCallback, compact('dataTable')); } if (is_callable($this->responseCallback)) { $data = new Collection($dataTable->toArray()); $response = app()->call($this->responseCallback, compact('data')); return new JsonResponse($response); } return $dataTable->toJson(); } /** * Display printable view of datatables. * * @return \Illuminate\Contracts\View\View */ public function printPreview(): Renderable { $data = $this->getDataForPrint(); return view($this->printPreview, compact('data')); } /** * Get mapped columns versus final decorated output. */ protected function getDataForPrint(): array { $columns = $this->printColumns(); return $this->mapResponseToColumns($columns, 'printable'); } /** * Get printable columns. */ protected function printColumns(): array|Collection { return is_array($this->printColumns) ? $this->toColumnsCollection($this->printColumns) : $this->getPrintColumnsFromBuilder(); } /** * Get filtered print columns definition from html builder. */ protected function getPrintColumnsFromBuilder(): Collection { return $this->html()->removeColumn(...$this->excludeFromPrint)->getColumns(); } /** * Get filtered export columns definition from html builder. */ protected function getExportColumnsFromBuilder(): Collection { return $this->html()->removeColumn(...$this->excludeFromExport)->getColumns(); } /** * Get columns definition from html builder. */ protected function getColumnsFromBuilder(): Collection { return $this->html()->getColumns(); } /** * Optional method if you want to use html builder. * * @return \Yajra\DataTables\Html\Builder */ public function html() { return $this->builder(); } /** * Get DataTables Html Builder instance. */ public function builder(): Builder { if (method_exists($this, 'htmlBuilder')) { return $this->htmlBuilder = $this->htmlBuilder(); } if (! $this->htmlBuilder) { $this->htmlBuilder = app(Builder::class); } return $this->htmlBuilder; } /** * Map ajax response to columns definition. */ protected function mapResponseToColumns(array|\Illuminate\Support\Collection $columns, string $type): array { $transformer = new DataArrayTransformer; return array_map(fn ($row) => $transformer->transform($row, $columns, $type), $this->getAjaxResponseData()); } /** * Get decorated data as defined in datatables ajax response. */ protected function getAjaxResponseData(): array { $this->request()->merge([ 'start' => 0, 'length' => -1, ]); /** @var JsonResponse $response */ $response = app()->call($this->ajax(...)); /** @var array{data: array} $data */ $data = $response->getData(true); return $data['data']; } protected function getHtmlBuilder(): Builder { $builder = $this->html(); if (is_callable($this->htmlCallback)) { app()->call($this->htmlCallback, compact('builder')); } return $builder; } /** * Add html builder callback hook. * * @return $this */ public function withHtml(callable $callback): static { $this->htmlCallback = $callback; return $this; } /** * Add callback before sending the response. * * @return $this */ public function before(callable $callback): static { $this->beforeCallback = $callback; return $this; } /** * Add callback after the response was processed. * * @return $this */ public function response(callable $callback): static { $this->responseCallback = $callback; return $this; } /** * Export results to Excel file. * * @return string|\Symfony\Component\HttpFoundation\BinaryFileResponse|\Symfony\Component\HttpFoundation\StreamedResponse * * @throws \Exception */ public function excel() { set_time_limit(3600); $path = $this->getFilename().'.'.strtolower($this->excelWriter); $excelFile = $this->buildExcelFile(); if ($excelFile instanceof FastExcel) { $callback = $this->fastExcelCallback ? $this->fastExcelCallback() : null; return $excelFile->download($path, $callback); } // @phpstan-ignore-next-line return $excelFile->download($path, $this->excelWriter); } /** * Build Excel file and prepare for export. * * @return mixed|FastExcel * * @throws \Exception */ protected function buildExcelFile() { if ($this->fastExcel) { return $this->buildFastExcelFile(); } if (! class_exists(ExcelServiceProvider::class)) { throw new Exception('Please `composer require maatwebsite/excel` to be able to use this function.'); } if (! new $this->exportClass instanceof DataTablesExportHandler) { $collection = $this->getAjaxResponseData(); return new $this->exportClass($this->convertToLazyCollection($collection)); } $collection = $this->getDataForExport(); return new $this->exportClass($this->convertToLazyCollection($collection)); } /** * Get export filename. */ public function getFilename(): string { return $this->filename ?: $this->filename(); } /** * Set export filename. * * @return $this */ public function setFilename(string $filename): static { $this->filename = $filename; return $this; } /** * Get filename for export. */ protected function filename(): string { return class_basename($this).'_'.date('YmdHis'); } /** * Get mapped columns versus final decorated output. */ protected function getDataForExport(): array { $columns = $this->exportColumns(); return $this->mapResponseToColumns($columns, 'exportable'); } /** * Get export columns definition. * * @return Collection<int, Column> */ protected function exportColumns(): Collection { return is_array($this->exportColumns) ? $this->toColumnsCollection($this->exportColumns) : $this->getExportColumnsFromBuilder(); } /** * Convert array to collection of Column class. */ private function toColumnsCollection(array $columns): Collection { $collection = new Collection; foreach ($columns as $column) { if (isset($column['data'])) { $column['title'] ??= $column['data']; $collection->push(new Column($column)); } else { $data = []; $data['data'] = $column; $data['title'] = $column; $collection->push(new Column($data)); } } return $collection; } /** * Export results to CSV file. * * @return string|\Symfony\Component\HttpFoundation\StreamedResponse * * @throws \Exception */ public function csv() { set_time_limit(3600); $path = $this->getFilename().'.'.strtolower($this->csvWriter); $excelFile = $this->buildExcelFile(); if ($excelFile instanceof FastExcel) { $callback = $this->fastExcelCallback ? $this->fastExcelCallback() : null; return $excelFile->download($path, $callback); } // @phpstan-ignore-next-line return $this->buildExcelFile()->download($path, $this->csvWriter); } /** * Export results to PDF file. * * @return \Illuminate\Http\Response|string|\Symfony\Component\HttpFoundation\StreamedResponse * * @throws \Exception */ public function pdf() { if (config('datatables-buttons.pdf_generator', 'snappy') == 'snappy') { return $this->snappyPdf(); } // @phpstan-ignore-next-line return $this->buildExcelFile()->download($this->getFilename().'.pdf', $this->pdfWriter); } /** * PDF version of the table using print preview blade template. * * * @throws \Yajra\DataTables\Exceptions\Exception */ public function snappyPdf(): Response { if (! class_exists(PdfWrapper::class)) { throw new Exception('Please `composer require barryvdh/laravel-snappy` to be able to use this feature.'); } /** @var \Barryvdh\Snappy\PdfWrapper $snappy */ $snappy = app('snappy.pdf.wrapper'); $options = (array) config('datatables-buttons.snappy.options'); /** @var string $orientation */ $orientation = config('datatables-buttons.snappy.orientation'); $snappy->setOptions($options)->setOrientation($orientation); return $snappy->loadHTML($this->printPreview())->download($this->getFilename().'.pdf'); } /** * Add basic array query scopes. * * @return $this */ public function addScope(DataTableScope $scope): static { $this->scopes[] = $scope; return $this; } /** * Push multiples scopes to array query scopes. * * @return $this */ public function addScopes(array $scopes): static { $this->scopes = array_merge($this->scopes, $scopes); return $this; } /** * Set a custom class attribute. * * @return $this */ public function with(array|string $key, mixed $value = null): static { if (is_array($key)) { $this->attributes = array_merge($this->attributes, $key); } else { $this->attributes[$key] = $value; } return $this; } /** * Dynamically retrieve the value of an attribute. * * @return mixed|null */ public function __get(string $key) { if (array_key_exists($key, $this->attributes)) { return $this->attributes[$key]; } return null; } /** * Apply query scopes. */ protected function applyScopes( EloquentBuilder|QueryBuilder|EloquentRelation|Collection|AnonymousResourceCollection $query ): EloquentBuilder|QueryBuilder|EloquentRelation|Collection|AnonymousResourceCollection { foreach ($this->scopes as $scope) { $scope->apply($query); } return $query; } /** * Determine if the DataTable has scopes. */ protected function hasScopes(array $scopes, bool $validateAll = false): bool { $filteredScopes = array_filter($this->scopes, fn ($scope) => in_array($scope::class, $scopes)); return $validateAll ? count($filteredScopes) === count($scopes) : ! empty($filteredScopes); } /** * Get default builder parameters. */ protected function getBuilderParameters(): array { /** @var array $defaults */ $defaults = config('datatables-buttons.parameters', []); return $defaults; } protected function convertToLazyCollection(array|Collection $collection): LazyCollection { if (is_array($collection)) { $collection = collect($collection); } return $collection->lazy(); } public function fastExcelCallback(): Closure { return function ($row) { $mapped = []; $this->exportColumns()->each(function (Column $column) use (&$mapped, $row) { if ($column['exportable']) { $mapped[$column['title']] = $row[$column['data']]; } }); return $mapped; }; } /** * @throws \Yajra\DataTables\Exceptions\Exception */ protected function buildFastExcelFile(): FastExcel { if (! class_exists(FastExcel::class)) { throw new Exception('Please `composer require rap2hpoutre/fast-excel` to be able to use this function.'); } $query = null; if (method_exists($this, 'query')) { /** @var EloquentBuilder|QueryBuilder $query */ $query = app()->call([$this, 'query']); $query = $this->applyScopes($query); } /** @var \Yajra\DataTables\DataTableAbstract $dataTable */ // @phpstan-ignore-next-line $dataTable = app()->call([$this, 'dataTable'], compact('query')); $dataTable->skipPaging(); if ($dataTable instanceof QueryDataTable) { $queryGenerator = function ($dataTable): Generator { foreach ($dataTable->getFilteredQuery()->cursor() as $row) { yield $row; } }; return new FastExcel($queryGenerator($dataTable)); } return new FastExcel($dataTable->toArray()['data']); } } src/Transformers/DataArrayTransformer.php 0000644 00000004374 15060250025 0014627 0 ustar 00 <?php namespace Yajra\DataTables\Transformers; use Illuminate\Support\Arr; use Illuminate\Support\Collection; use Yajra\DataTables\Html\Column; class DataArrayTransformer { /** * Transform row data by column's definition. * * @param array|Collection<array-key, Column> $columns */ public function transform(array $row, array|Collection $columns, string $type = 'printable'): array { if ($columns instanceof Collection) { return $this->buildColumnByCollection($row, $columns, $type); } return Arr::only($row, $columns); } /** * Transform row column by collection. * * @param Collection<array-key, Column> $columns */ protected function buildColumnByCollection(array $row, Collection $columns, string $type = 'printable'): array { $results = []; $columns->each(function (Column $column) use ($row, $type, &$results) { if ($column[$type]) { $title = $column->title; if (is_array($column->data)) { $key = $column->data['filter'] ?? $column->name ?? ''; } else { $key = $column->data ?? $column->name; } $data = Arr::get($row, $key) ?? ''; if ($type == 'exportable') { $title = $this->decodeContent($title); $data = is_array($data) ? json_encode($data, JSON_THROW_ON_ERROR) : $this->decodeContent($data); } if (isset($column->exportRender)) { $callback = $column->exportRender; $results[$title] = $callback($row, $data); } else { $results[$title] = $data; } } }); return $results; } /** * Decode content to a readable text value. */ protected function decodeContent(mixed $data): mixed { if (is_bool($data)) { return $data ? 'True' : 'False'; } if (is_string($data)) { $decoded = html_entity_decode(trim(strip_tags($data)), ENT_QUOTES, 'UTF-8'); return (string) str_replace("\xc2\xa0", ' ', $decoded); } return $data; } } src/Exports/DataTablesCollectionExport.php 0000644 00000001600 15060250025 0014722 0 ustar 00 <?php namespace Yajra\DataTables\Exports; use Illuminate\Support\Collection; use Illuminate\Support\LazyCollection; use Maatwebsite\Excel\Concerns\Exportable; use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\WithHeadings; abstract class DataTablesCollectionExport implements FromCollection, WithHeadings { use Exportable; protected LazyCollection|Collection $collection; public function __construct(Collection|LazyCollection|null $collection = null) { $this->collection = $collection ?? new Collection; } public function collection(): Collection|LazyCollection { return $this->collection; } public function headings(): array { /** @var array $first */ $first = $this->collection->first(); if ($first) { return array_keys($first); } return []; } } src/ButtonsServiceProvider.php 0000644 00000003453 15060250025 0012536 0 ustar 00 <?php namespace Yajra\DataTables; use Illuminate\Support\ServiceProvider; use Maatwebsite\Excel\ExcelServiceProvider; use Yajra\DataTables\Generators\DataTablesHtmlCommand; use Yajra\DataTables\Generators\DataTablesMakeCommand; use Yajra\DataTables\Generators\DataTablesScopeCommand; class ButtonsServiceProvider extends ServiceProvider { /** * Bootstrap the application events. */ public function boot(): void { $this->loadViewsFrom(__DIR__.'/resources/views', 'datatables'); $this->publishAssets(); $this->registerCommands(); } /** * Publish datatables assets. */ protected function publishAssets(): void { $this->publishes([ __DIR__.'/config/config.php' => config_path('datatables-buttons.php'), ], 'datatables-buttons'); $this->publishes([ __DIR__.'/resources/assets/buttons.server-side.js' => public_path('vendor/datatables/buttons.server-side.js'), ], 'datatables-buttons'); $this->publishes([ __DIR__.'/resources/views' => base_path('/resources/views/vendor/datatables'), ], 'datatables-buttons'); } /** * Register datatables commands. */ protected function registerCommands(): void { $this->commands(DataTablesMakeCommand::class); $this->commands(DataTablesScopeCommand::class); $this->commands(DataTablesHtmlCommand::class); } /** * Register the service provider. */ public function register(): void { $this->mergeConfigFrom(__DIR__.'/config/config.php', 'datatables-buttons'); $this->app->register(HtmlServiceProvider::class); if (class_exists(ExcelServiceProvider::class)) { $this->app->register(ExcelServiceProvider::class); } } } src/Generators/DataTablesScopeCommand.php 0000644 00000002061 15060250025 0014444 0 ustar 00 <?php namespace Yajra\DataTables\Generators; use Illuminate\Console\GeneratorCommand; class DataTablesScopeCommand extends GeneratorCommand { /** * The console command name. * * @var string */ protected $name = 'datatables:scope'; /** * The console command description. * * @var string */ protected $description = 'Create a new DataTable Scope class.'; /** * The type of class being generated. * * @var string */ protected $type = 'DataTable Scope'; /** * Get the default namespace for the class. * * @param string $rootNamespace */ protected function getDefaultNamespace($rootNamespace): string { return $rootNamespace.'\DataTables\Scopes'; } /** * Get the stub file for the generator. */ protected function getStub(): string { if ($stubFolder = config('datatables-buttons.stub')) { return base_path($stubFolder.'/scopes.stub'); } return __DIR__.'/stubs/scopes.stub'; } } src/Generators/stubs/builder.stub 0000644 00000002106 15060250025 0013123 0 ustar 00 <?php namespace DummyNamespace; use DummyModel; use Illuminate\Database\Eloquent\Builder as QueryBuilder; use Yajra\DataTables\EloquentDataTable; use Yajra\DataTables\Html\Builder as HtmlBuilder; use Yajra\DataTables\Services\DataTable; class DummyClass extends DataTable { /** * Build the DataTable class. * * @param QueryBuilder $query Results from query() method. */ public function dataTable(QueryBuilder $query): EloquentDataTable { return (new EloquentDataTable($query)) ->addColumn('action', 'DummyAction') ->setRowId('id'); } /** * Get the query source of dataTable. */ public function query(ModelName $model): QueryBuilder { return $model->newQuery(); } /** * Optional method if you want to use the html builder. */ public function html(): HtmlBuilder { return DummyBuilder::make(); } /** * Get the filename for export. */ protected function filename(): string { return 'DummyFilename_' . date('YmdHis'); } } src/Generators/stubs/datatables.stub 0000644 00000003624 15060250025 0013607 0 ustar 00 <?php namespace DummyNamespace; use DummyModel; use Yajra\DataTables\Html\Button; use Yajra\DataTables\Html\Column; use Yajra\DataTables\Services\DataTable; use Yajra\DataTables\Html\Editor\Fields; use Yajra\DataTables\Html\Editor\Editor; use Illuminate\Database\Eloquent\Builder as QueryBuilder; use Yajra\DataTables\EloquentDataTable; use Yajra\DataTables\Html\Builder as HtmlBuilder; class DummyClass extends DataTable { /** * Build the DataTable class. * * @param QueryBuilder $query Results from query() method. */ public function dataTable(QueryBuilder $query): EloquentDataTable { return (new EloquentDataTable($query)) ->addColumn('action', 'DummyAction') ->setRowId('id'); } /** * Get the query source of dataTable. */ public function query(ModelName $model): QueryBuilder { return $model->newQuery(); } /** * Optional method if you want to use the html builder. */ public function html(): HtmlBuilder { return $this->builder() ->setTableId('DummyTableId') ->columns($this->getColumns()) ->minifiedAjax() //->dom('DummyDOM') ->orderBy(1) ->selectStyleSingle() ->buttons([ DummyButtons ]); } /** * Get the dataTable columns definition. */ public function getColumns(): array { return [ Column::computed('action') ->exportable(false) ->printable(false) ->width(60) ->addClass('text-center'), DummyColumns ]; } /** * Get the filename for export. */ protected function filename(): string { return 'DummyFilename_' . date('YmdHis'); } } src/Generators/stubs/html.stub 0000644 00000002114 15060250025 0012440 0 ustar 00 <?php namespace DummyNamespace; use Yajra\DataTables\Html\Button; use Yajra\DataTables\Html\Column; use Yajra\DataTables\Html\DataTableHtml; use Yajra\DataTables\Html\Editor\Fields; use Yajra\DataTables\Html\Editor\Editor; class DummyClass extends DataTableHtml { /** * Build the html builder. * * @throws \Exception */ public function handle(): Builder { return $this->setTableId('DummyTableId') ->columns($this->getColumns()) ->minifiedAjax() //->dom('DummyDOM') ->orderBy(1) ->selectStyleSingle() ->buttons([ DummyButtons ]); } /** * Get the dataTable columns definition. */ public function getColumns(): array { return [ Column::computed('action') ->exportable(false) ->printable(false) ->width(60) ->addClass('text-center'), DummyColumns ]; } } src/Generators/stubs/scopes.stub 0000644 00000000577 15060250025 0013003 0 ustar 00 <?php namespace DummyNamespace; use Yajra\DataTables\Contracts\DataTableScope; class DummyClass implements DataTableScope { /** * Apply a query scope. * * @param \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder $query * @return mixed */ public function apply($query) { // return $query->where('id', 1); } } src/Generators/DataTablesMakeCommand.php 0000644 00000024101 15060250025 0014247 0 ustar 00 <?php namespace Yajra\DataTables\Generators; use Illuminate\Console\GeneratorCommand; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; class DataTablesMakeCommand extends GeneratorCommand { /** * The name and signature of the console command. * * @var string */ protected $signature = 'datatables:make {name : The name of the DataTable.} {--model= : The name of the model to be used.} {--model-namespace= : The namespace of the model to be used.} {--action= : The path of the action view.} {--table= : Scaffold columns from the table.} {--builder : Extract html() to a Builder class.} {--dom= : The dom of the DataTable.} {--buttons= : The buttons of the DataTable.} {--columns= : The columns of the DataTable.}'; /** * The console command description. * * @var string */ protected $description = 'Create a new DataTable service class.'; /** * The type of class being generated. * * @var string */ protected $type = 'DataTable'; public function handle() { parent::handle(); if ($this->option('builder')) { $columns = config('datatables-buttons.generator.columns', 'id,add your columns,created_at,updated_at'); $buttons = config('datatables-buttons.generator.buttons', 'create,export,print,reset,reload'); $dom = config('datatables-buttons.generator.dom', 'Bfrtip'); $this->call('datatables:html', [ 'name' => $this->getDataTableBaseName(), '--columns' => $this->option('columns') ?: $columns, '--buttons' => $this->option('buttons') ?: $buttons, '--dom' => $this->option('dom') ?: $dom, '--table' => $this->option('table'), ]); } } /** * Build the class with the given name. * * @param string $name * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ protected function buildClass($name): string { $stub = parent::buildClass($name); $this->replaceModelImport($stub) ->replaceModel($stub) ->replaceBuilder($stub) ->replaceColumns($stub) ->replaceButtons($stub) ->replaceDOM($stub) ->replaceTableId($stub) ->replaceAction($stub) ->replaceFilename($stub); return $stub; } /** * Get DataTable class base name without the suffix. */ protected function getDataTableBaseName(): string { return (string) preg_replace('#datatable$#i', '', (string) $this->getNameInput()); } /** * Prepare model name from input. */ protected function prepareModelName(): string { return basename($this->getDataTableBaseName()); } /** * Replace the filename. * * @return $this */ protected function replaceFilename(string &$stub): static { $stub = str_replace('DummyFilename', $this->prepareModelName(), $stub); return $this; } /** * Replace the action. */ protected function replaceAction(string &$stub): static { $stub = str_replace('DummyAction', $this->getAction(), $stub); return $this; } /** * Set the action view to be used. */ protected function getAction(): string { /** @var string $action */ $action = $this->option('action'); if ($action) { return $action; } return Str::lower($this->prepareModelName()).'.action'; } /** * Replace columns. * * @return $this */ protected function replaceTableId(string &$stub): static { $stub = str_replace('DummyTableId', Str::lower($this->prepareModelName()).'-table', $stub); return $this; } /** * Replace dom. * * @return $this */ protected function replaceDOM(string &$stub): static { /** @var string $dom */ $dom = $this->option('dom') ?: config('datatables-buttons.generator.dom', 'Bfrtip'); $stub = str_replace('DummyDOM', $dom, $stub); return $this; } /** * Replace buttons. * * @return $this */ protected function replaceButtons(string &$stub): static { $stub = str_replace('DummyButtons', $this->getButtons(), $stub); return $this; } /** * Get the columns to be used. */ protected function getButtons(): string { /** @var string $buttons */ $buttons = $this->option('buttons'); if ($buttons) { return $this->parseButtons($buttons); } /** @var string $buttons */ $buttons = config('datatables-buttons.generator.buttons', 'create,export,print,reset,reload'); return $this->parseButtons($buttons); } /** * Parse array from definition. */ protected function parseButtons(string $definition, int $indentation = 24): string { $columns = explode(',', $definition); $stub = ''; foreach ($columns as $key => $column) { $indent = ''; $separator = ','; if ($key < count($columns) - 1) { $indent = PHP_EOL.str_repeat(' ', $indentation); } if ($key == count($columns) - 1) { $separator = ''; } $stub .= "Button::make('{$column}')".$separator.$indent; } return $stub; } /** * Replace columns. * * @return $this */ protected function replaceColumns(string &$stub): static { $stub = str_replace('DummyColumns', $this->getColumns(), $stub); return $this; } /** * Get the columns to be used. */ protected function getColumns(): string { /** @var string $table */ $table = $this->option('table'); if ($table) { return $this->parseColumns(Schema::getColumnListing($table)); } /** @var string $columns */ $columns = $this->option('columns'); if ($columns) { return $this->parseColumns($columns); } /** @var string $columns */ $columns = config('datatables-buttons.generator.columns', 'id,add your columns,created_at,updated_at'); return $this->parseColumns($columns); } /** * Parse array from definition. */ protected function parseColumns(array|string $definition, int $indentation = 12): string { $columns = is_array($definition) ? $definition : explode(',', $definition); $stub = ''; foreach ($columns as $key => $column) { $stub .= "Column::make('{$column}'),"; if ($key < count($columns) - 1) { $stub .= PHP_EOL.str_repeat(' ', $indentation); } } return $stub; } /** * Replace builder name. * * @param string $stub * @return \Yajra\DataTables\Generators\DataTablesMakeCommand */ protected function replaceBuilder(&$stub) { $name = $this->qualifyClass($this->getNameInput()); $class = str_replace($this->getNamespace($name).'\\', '', $name); $stub = str_replace('DummyBuilder', $class.'Html', $stub); return $this; } /** * Parse the name and format according to the root namespace. * * @param string $name * @return string */ protected function qualifyClass($name) { $rootNamespace = $this->laravel->getNamespace(); if (Str::startsWith($name, $rootNamespace)) { return $name; } if (Str::contains($name, '/')) { $name = str_replace('/', '\\', $name); } if (! Str::contains(Str::lower($name), 'datatable')) { $name .= 'DataTable'; } else { $name = preg_replace('#datatable$#i', 'DataTable', $name); } return $this->getDefaultNamespace(trim((string) $rootNamespace, '\\')).'\\'.$name; } /** * Get the default namespace for the class. * * @param string $rootNamespace */ protected function getDefaultNamespace($rootNamespace): string { return $rootNamespace.'\\'.config('datatables-buttons.namespace.base', 'DataTables'); } /** * Replace model name. */ protected function replaceModel(string &$stub): static { $model = explode('\\', $this->getModel()); $model = array_pop($model); $stub = str_replace('ModelName', $model, $stub); return $this; } /** * Get model name to use. */ protected function getModel(): string { /** @var string $modelFromOption */ $modelFromOption = $this->option('model'); $modelNamespaceFromOption = $this->option('model-namespace') ?: config('datatables-buttons.namespace.model'); $name = $modelFromOption ?: $this->prepareModelName(); $modelNamespace = $modelNamespaceFromOption ?: $this->laravel->getNamespace(); if (empty($modelNamespaceFromOption) && is_dir(app_path('Models'))) { $modelNamespace = $modelNamespace.'\\Models\\'; } return $modelNamespace.'\\'.Str::singular($name); } /** * Replace model import. * * @return $this */ protected function replaceModelImport(string &$stub): static { $stub = str_replace('DummyModel', str_replace('\\\\', '\\', $this->getModel()), $stub); return $this; } /** * Get the stub file for the generator. */ protected function getStub(): string { $stub = 'datatables.stub'; if ($this->option('builder')) { $stub = 'builder.stub'; } return config('datatables-buttons.stub') ? base_path().config('datatables-buttons.stub')."/$stub" : __DIR__."/stubs/{$stub}"; } } src/Generators/DataTablesHtmlCommand.php 0000644 00000005030 15060250025 0014276 0 ustar 00 <?php namespace Yajra\DataTables\Generators; use Illuminate\Support\Str; class DataTablesHtmlCommand extends DataTablesMakeCommand { /** * The name and signature of the console command. * * @var string */ protected $signature = 'datatables:html {name : The name of the DataTable html.} {--dom= : The dom of the DataTable.} {--buttons= : The buttons of the DataTable.} {--table= : Scaffold columns from the table.} {--builder : Ignore, added to work with parent generator.} {--columns= : The columns of the DataTable.}'; /** * The console command description. * * @var string */ protected $description = 'Create a new DataTable html class.'; /** * The type of class being generated. * * @var string */ protected $type = 'DataTableHtml'; /** * Build the class with the given name. * * @param string $name * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ protected function buildClass($name): string { $stub = $this->files->get($this->getStub()); $stub = $this->replaceNamespace($stub, $name)->replaceClass($stub, $name); $this->replaceBuilder($stub) ->replaceColumns($stub) ->replaceButtons($stub) ->replaceDOM($stub) ->replaceTableId($stub); return $stub; } /** * Get the stub file for the generator. */ protected function getStub(): string { return config('datatables-buttons.stub') ? base_path().config('datatables-buttons.stub').'/html.stub' : __DIR__.'/stubs/html.stub'; } /** * Parse the name and format according to the root namespace. * * @param string $name */ protected function qualifyClass($name): string { $rootNamespace = $this->laravel->getNamespace(); if (Str::startsWith($name, $rootNamespace)) { return $name; } if (Str::contains($name, '/')) { $name = str_replace('/', '\\', $name); } if (! Str::contains(Str::lower($name), 'datatablehtml')) { $name .= 'DataTableHtml'; } else { $name = preg_replace('#datatablehtml$#i', 'DataTableHtml', $name); } return $this->getDefaultNamespace(trim((string) $rootNamespace, '\\')).'\\'.$name; } } src/resources/views/print.blade.php 0000644 00000002503 15060250025 0013410 0 ustar 00 <!DOCTYPE html> <html lang="en"> <head> <title>Print Table</title> <meta charset="UTF-8"> <meta name=description content=""> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Bootstrap CSS --> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> <style> body {margin: 20px} </style> </head> <body> <table class="table table-bordered table-condensed table-striped"> @foreach($data as $row) @if ($loop->first) <tr> @foreach($row as $key => $value) <th>{!! $key !!}</th> @endforeach </tr> @endif <tr> @foreach($row as $key => $value) @if(is_string($value) || is_numeric($value)) <td>{!! $value !!}</td> @else <td></td> @endif @endforeach </tr> @endforeach </table> </body> </html> src/resources/assets/buttons.server-side.js 0000644 00000021560 15060250025 0015131 0 ustar 00 (function ($, DataTable) { "use strict"; var _buildParams = function (dt, action, onlyVisibles) { var params = dt.ajax.params(); params.action = action; params._token = $('meta[name="csrf-token"]').attr('content'); if (onlyVisibles) { params.visible_columns = _getVisibleColumns(); } else { params.visible_columns = null; } return params; }; var _getVisibleColumns = function () { var visible_columns = []; $.each(DataTable.settings[0].aoColumns, function (key, col) { if (col.bVisible) { visible_columns.push(col.name); } }); return visible_columns; }; var _downloadFromUrl = function (url, params) { var postUrl = url + '/export'; var xhr = new XMLHttpRequest(); xhr.open('POST', postUrl, true); xhr.responseType = 'arraybuffer'; xhr.onload = function () { if (this.status === 200) { var filename = ""; var disposition = xhr.getResponseHeader('Content-Disposition'); if (disposition && disposition.indexOf('attachment') !== -1) { var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/; var matches = filenameRegex.exec(disposition); if (matches != null && matches[1]) filename = matches[1].replace(/['"]/g, ''); } var type = xhr.getResponseHeader('Content-Type'); var blob = new Blob([this.response], {type: type}); if (typeof window.navigator.msSaveBlob !== 'undefined') { // IE workaround for "HTML7007: One or more blob URLs were revoked by closing the blob for which they were created. These URLs will no longer resolve as the data backing the URL has been freed." window.navigator.msSaveBlob(blob, filename); } else { var URL = window.URL || window.webkitURL; var downloadUrl = URL.createObjectURL(blob); if (filename) { // use HTML5 a[download] attribute to specify filename var a = document.createElement("a"); // safari doesn't support this yet if (typeof a.download === 'undefined') { window.location = downloadUrl; } else { a.href = downloadUrl; a.download = filename; document.body.appendChild(a); a.click(); } } else { window.location = downloadUrl; } setTimeout(function () { URL.revokeObjectURL(downloadUrl); }, 100); // cleanup } } }; xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.send($.param(params)); }; var _buildUrl = function(dt, action) { var url = dt.ajax.url() || ''; var params = dt.ajax.params(); params.action = action; if (url.indexOf('?') > -1) { return url + '&' + $.param(params); } return url + '?' + $.param(params); }; DataTable.ext.buttons.excel = { className: 'buttons-excel', text: function (dt) { return '<i class="fa fa-file-excel-o"></i> ' + dt.i18n('buttons.excel', 'Excel'); }, action: function (e, dt, button, config) { var url = _buildUrl(dt, 'excel'); window.location = url; } }; DataTable.ext.buttons.postExcel = { className: 'buttons-excel', text: function (dt) { return '<i class="fa fa-file-excel-o"></i> ' + dt.i18n('buttons.excel', 'Excel'); }, action: function (e, dt, button, config) { var url = dt.ajax.url() || window.location.href; var params = _buildParams(dt, 'excel'); _downloadFromUrl(url, params); } }; DataTable.ext.buttons.postExcelVisibleColumns = { className: 'buttons-excel', text: function (dt) { return '<i class="fa fa-file-excel-o"></i> ' + dt.i18n('buttons.excel', 'Excel (only visible columns)'); }, action: function (e, dt, button, config) { var url = dt.ajax.url() || window.location.href; var params = _buildParams(dt, 'excel', true); _downloadFromUrl(url, params); } }; DataTable.ext.buttons.export = { extend: 'collection', className: 'buttons-export', text: function (dt) { return '<i class="fa fa-download"></i> ' + dt.i18n('buttons.export', 'Export') + ' <span class="caret"/>'; }, buttons: ['csv', 'excel', 'pdf'] }; DataTable.ext.buttons.csv = { className: 'buttons-csv', text: function (dt) { return '<i class="fa fa-file-excel-o"></i> ' + dt.i18n('buttons.csv', 'CSV'); }, action: function (e, dt, button, config) { var url = _buildUrl(dt, 'csv'); window.location = url; } }; DataTable.ext.buttons.postCsvVisibleColumns = { className: 'buttons-csv', text: function (dt) { return '<i class="fa fa-file-excel-o"></i> ' + dt.i18n('buttons.csv', 'CSV (only visible columns)'); }, action: function (e, dt, button, config) { var url = dt.ajax.url() || window.location.href; var params = _buildParams(dt, 'csv', true); _downloadFromUrl(url, params); } }; DataTable.ext.buttons.postCsv = { className: 'buttons-csv', text: function (dt) { return '<i class="fa fa-file-excel-o"></i> ' + dt.i18n('buttons.csv', 'CSV'); }, action: function (e, dt, button, config) { var url = dt.ajax.url() || window.location.href; var params = _buildParams(dt, 'csv'); _downloadFromUrl(url, params); } }; DataTable.ext.buttons.pdf = { className: 'buttons-pdf', text: function (dt) { return '<i class="fa fa-file-pdf-o"></i> ' + dt.i18n('buttons.pdf', 'PDF'); }, action: function (e, dt, button, config) { var url = _buildUrl(dt, 'pdf'); window.location = url; } }; DataTable.ext.buttons.postPdf = { className: 'buttons-pdf', text: function (dt) { return '<i class="fa fa-file-pdf-o"></i> ' + dt.i18n('buttons.pdf', 'PDF'); }, action: function (e, dt, button, config) { var url = dt.ajax.url() || window.location.href; var params = _buildParams(dt, 'pdf'); _downloadFromUrl(url, params); } }; DataTable.ext.buttons.print = { className: 'buttons-print', text: function (dt) { return '<i class="fa fa-print"></i> ' + dt.i18n('buttons.print', 'Print'); }, action: function (e, dt, button, config) { var url = _buildUrl(dt, 'print'); window.location = url; } }; DataTable.ext.buttons.reset = { className: 'buttons-reset', text: function (dt) { return '<i class="fa fa-undo"></i> ' + dt.i18n('buttons.reset', 'Reset'); }, action: function (e, dt, button, config) { dt.search(''); dt.columns().search(''); dt.draw(); } }; DataTable.ext.buttons.reload = { className: 'buttons-reload', text: function (dt) { return '<i class="fa fa-refresh"></i> ' + dt.i18n('buttons.reload', 'Reload'); }, action: function (e, dt, button, config) { dt.draw(false); } }; DataTable.ext.buttons.create = { className: 'buttons-create', text: function (dt) { return '<i class="fa fa-plus"></i> ' + dt.i18n('buttons.create', 'Create'); }, action: function (e, dt, button, config) { window.location = window.location.href.replace(/\/+$/, "") + '/create'; } }; if (typeof DataTable.ext.buttons.copyHtml5 !== 'undefined') { $.extend(DataTable.ext.buttons.copyHtml5, { text: function (dt) { return '<i class="fa fa-copy"></i> ' + dt.i18n('buttons.copy', 'Copy'); } }); } if (typeof DataTable.ext.buttons.colvis !== 'undefined') { $.extend(DataTable.ext.buttons.colvis, { text: function (dt) { return '<i class="fa fa-eye"></i> ' + dt.i18n('buttons.colvis', 'Column visibility'); } }); } })(jQuery, jQuery.fn.dataTable); src/Html/DataTableHtml.php 0000644 00000002345 15060250025 0011415 0 ustar 00 <?php namespace Yajra\DataTables\Html; use BadMethodCallException; use Yajra\DataTables\Contracts\DataTableHtmlBuilder; /** * @mixin Builder */ abstract class DataTableHtml implements DataTableHtmlBuilder { protected ?Builder $htmlBuilder = null; public static function make(): Builder { if (func_get_args()) { return (new static(...func_get_args()))->handle(); } /** @var static $html */ $html = app(static::class); return $html->handle(); } /** * @return \Yajra\DataTables\Html\Builder * * @throws \Exception */ public function __call(string $method, mixed $parameters) { if (method_exists($this->getHtmlBuilder(), $method)) { return $this->getHtmlBuilder()->{$method}(...$parameters); } throw new BadMethodCallException("Method {$method} does not exists"); } protected function getHtmlBuilder(): Builder { if ($this->htmlBuilder) { return $this->htmlBuilder; } return $this->htmlBuilder = app(Builder::class); } public function setHtmlBuilder(Builder $builder): static { $this->htmlBuilder = $builder; return $this; } } src/Contracts/DataTableHtmlBuilder.php 0000644 00000000337 15060250025 0013757 0 ustar 00 <?php namespace Yajra\DataTables\Contracts; interface DataTableHtmlBuilder { /** * Handle building of dataTables html. * * @return \Yajra\DataTables\Html\Builder */ public function handle(); } src/Contracts/DataTableScope.php 0000644 00000000642 15060250025 0012614 0 ustar 00 <?php namespace Yajra\DataTables\Contracts; interface DataTableScope { /** * Apply a query scope. * * @param \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Relations\Relation|\Illuminate\Support\Collection|\Illuminate\Http\Resources\Json\AnonymousResourceCollection $query * @return mixed */ public function apply($query); } src/Contracts/DataTableButtons.php 0000644 00000000760 15060250025 0013202 0 ustar 00 <?php namespace Yajra\DataTables\Contracts; interface DataTableButtons { /** * Export to excel file. * * @return mixed */ public function excel(); /** * Export to CSV file. * * @return mixed */ public function csv(); /** * Export to PDF file. * * @return mixed */ public function pdf(); /** * Display printer friendly view. * * @return mixed */ public function printPreview(); } src/config/config.php 0000644 00000004320 15060250025 0010550 0 ustar 00 <?php return [ /* * Namespaces used by the generator. */ 'namespace' => [ /* * Base namespace/directory to create the new file. * This is appended on default Laravel namespace. * Usage: php artisan datatables:make User * Output: App\DataTables\UserDataTable * With Model: App\User (default model) * Export filename: users_timestamp */ 'base' => 'DataTables', /* * Base namespace/directory where your model's are located. * This is appended on default Laravel namespace. * Usage: php artisan datatables:make Post --model * Output: App\DataTables\PostDataTable * With Model: App\Post * Export filename: posts_timestamp */ 'model' => 'App\\Models', ], /* * Set Custom stub folder */ //'stub' => '/resources/custom_stub', /* * PDF generator to be used when converting the table to pdf. * Available generators: excel, snappy * Snappy package: barryvdh/laravel-snappy * Excel package: maatwebsite/excel */ 'pdf_generator' => 'snappy', /* * Snappy PDF options. */ 'snappy' => [ 'options' => [ 'no-outline' => true, 'margin-left' => '0', 'margin-right' => '0', 'margin-top' => '10mm', 'margin-bottom' => '10mm', ], 'orientation' => 'landscape', ], /* * Default html builder parameters. */ 'parameters' => [ 'dom' => 'Bfrtip', 'order' => [[0, 'desc']], 'buttons' => [ 'excel', 'csv', 'pdf', 'print', 'reset', 'reload', ], ], /* * Generator command default options value. */ 'generator' => [ /* * Default columns to generate when not set. */ 'columns' => 'id,add your columns,created_at,updated_at', /* * Default buttons to generate when not set. */ 'buttons' => 'excel,csv,pdf,print,reset,reload', /* * Default DOM to generate when not set. */ 'dom' => 'Bfrtip', ], ]; CONTRIBUTING.md 0000644 00000001652 15060250025 0006774 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-buttons). ## 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 15060250025 0006144 0 ustar 00 (The MIT License) Copyright (c) 2013-2018 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. rector.php 0000644 00000001032 15060250025 0006542 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, ]); }; CHANGELOG.md 0000644 00000000140 15060250025 0006343 0 ustar 00 # Laravel DataTables Buttons Plugin CHANGELOG. ## v11.0.0 - 2024-03-14 - Laravel 11.x support composer.json 0000644 00000004436 15060250025 0007270 0 ustar 00 { "name": "yajra/laravel-datatables-buttons", "description": "Laravel DataTables Buttons Plugin.", "keywords": [ "laravel", "datatables", "buttons", "jquery" ], "license": "MIT", "authors": [ { "name": "Arjay Angeles", "email": "aqangeles@gmail.com" } ], "require": { "php": "^8.2", "yajra/laravel-datatables-oracle": "^11", "yajra/laravel-datatables-html": "^11", "illuminate/console": "^11" }, "require-dev": { "larastan/larastan": "^2.9.2", "orchestra/testbench": "^9", "laravel/pint": "^1.14", "rector/rector": "^1.0.2", "maatwebsite/excel": "^3.1.55", "rap2hpoutre/fast-excel": "^5.4" }, "autoload": { "psr-4": { "Yajra\\DataTables\\": "src/" } }, "autoload-dev": { "psr-4": { "Yajra\\DataTables\\Buttons\\Tests\\": "tests/" } }, "extra": { "branch-alias": { "dev-master": "11.0-dev" }, "laravel": { "providers": [ "Yajra\\DataTables\\ButtonsServiceProvider" ] } }, "suggest": { "yajra/laravel-datatables-export": "Exporting of dataTables (excel, csv and PDF) via livewire and queue worker.", "maatwebsite/excel": "Exporting of dataTables (excel, csv and PDF) using maatwebsite package.", "rap2hpoutre/fast-excel": "Faster exporting of dataTables using fast-excel package.", "dompdf/dompdf": "Allows exporting of dataTable to PDF using the DomPDF.", "barryvdh/laravel-snappy": "Allows exporting of dataTable to PDF using the print view." }, "scripts": { "test": "./vendor/bin/phpunit", "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": [ "@pint", "@rector", "@stan", "@test" ] }, "minimum-stability": "dev", "prefer-stable": true, "funding": [ { "type": "github", "url": "https://github.com/sponsors/yajra" } ] } README.md 0000644 00000005675 15060250025 0006033 0 ustar 00 # Laravel DataTables Buttons Plugin [](http://laravel.com) [](https://packagist.org/packages/yajra/laravel-datatables-buttons) [](https://github.com/yajra/laravel-datatables-buttons/actions/workflows/continuous-integration.yml) [](https://github.com/yajra/laravel-datatables-buttons/actions/workflows/static-analysis.yml) [](https://scrutinizer-ci.com/g/yajra/laravel-datatables-buttons/?branch=master) [](https://packagist.org/packages/yajra/laravel-datatables-buttons) [](https://packagist.org/packages/yajra/laravel-datatables-buttons) This package is a plugin of [Laravel DataTables](https://github.com/yajra/laravel-datatables) for handling server-side function of exporting the table as csv, excel, pdf and printing. ## Requirements - [PHP >= 8.2](http://php.net/) - [Laravel 11.x](https://github.com/laravel/framework) - [Laravel DataTables](https://github.com/yajra/laravel-datatables) - [jQuery DataTables v1.10.x](http://datatables.net/) - [jQuery DataTables Buttons Extension](https://datatables.net/reference/button/) ## Documentations - [Laravel DataTables Documentation](http://yajrabox.com/docs/laravel-datatables) ## Laravel Version Compatibility | Laravel | Package | |:--------------|:--------| | 8.x and below | 4.x | | 9.x | 9.x | | 10.x | 10.x | | 11.x | 11.x | ## Quick Installation `composer require yajra/laravel-datatables-buttons:^11` #### Service Provider (Optional on Laravel 5.5) `Yajra\DataTables\ButtonsServiceProvider::class` #### Configuration and Assets (Optional) `$ php artisan vendor:publish --tag=datatables-buttons --force` And that's it! Start building out some awesome DataTables! ## Contributing Please see [CONTRIBUTING](https://github.com/yajra/laravel-datatables-buttons/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-buttons/graphs/contributors) ## License The MIT License (MIT). Please see [License File](https://github.com/yajra/laravel-datatables-buttons/blob/master/LICENSE.md) for more information. UPGADE.md 0000644 00000001050 15060250025 0006022 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-buttons": "^11.0" } ``` 2. Run `composer update` to update the package. 3. If you are using a custom class of laravel-excel to export the data, you need to update the collection method and include the return type `Collection|LazyCollection` in the method signature. ```php public function collection(): Collection|LazyCollection { return $this->collection; } ```
| ver. 1.4 |
Github
|
.
| PHP 8.2.29 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка