Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Crud Bundle Laravel Package

araise/crud-bundle

View on GitHub
Deep Wiki
Context7

Exporting

The CrudBundle allows you to easily export your data from a Table View to CSV files. For doing so follow these steps:

1: Enable the export route in your definition:

/**
 * {[@inheritdoc](https://github.com/inheritdoc)}
 */
public static function getCapabilities()
{
    return [
        Page::INDEX,
        Page::SHOW,
        Page::DELETE,
        Page::EDIT,
        Page::CREATE,
        Page::EXPORT			<----- Export Route
    ];
}

You now see an export button at the bottom of your table.

By default, the table configuration will be exported.

Customization

To define your custom export, just override the configureExport method. Create columns as you need them.

public function configureExport(Table $table)
{
    $this->configureTable($table);

    $table->addColumn('id', null, [
        Column::OPTION_PRIORITY => 200
    ])
    ->addColumn('jobTitle');
}

Export Column options

public function configureTable(Table $table): void
{
    parent::configureTable($table);
    $table
        ->addColumn('name', null, [
            Column::OPTION_EXPORT => [
                Column::OPTION_EXPORT_EXPORTABLE => false
                Column::OPTION_EXPORT_TEXTWRAP => true
            ]
        ])
    ;
}

Multiple Exporter

It is also possible to add your own exporter to the default one and therefore provide multiple exporter to the user. For this you first have to create your own exporter and implement the ExporterInterface:

<?php

namespace App\Exporter;

use Symfony\Contracts\Translation\TranslatorInterface;

class ExampleExporter implements ExporterInterface
{


    # Inject the services you need
    public function __construct(
        private TranslatorInterface $translator,
    ) {
    }

    public function createSpreadsheet(Table $table, $spreadsheet = new Spreadsheet()): Spreadsheet
    {
        $spreadsheet = new Spreadsheet();
        $activeWorksheet = $spreadsheet->getActiveSheet();
        $entries = $table->getRows();
        
        # Build your spreadsheet

        return $spreadsheet;
    }

}

In your definition you can add your new exporter to the table. For this override the configureTableExporter method and pass the acronym and the exporter:

public function configureTableExporter(Table $table): void
{
    parent::configureTableExporter($table);
    # translation key in this example equals to -> wwd.app_entity_example.exporter.acronym_for_translation
    $table->addExporter('acronym_for_translation', $this->exampleExporter); 
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk