Skip to content

Latest commit

 

History

History
68 lines (47 loc) · 2.27 KB

usage.md

File metadata and controls

68 lines (47 loc) · 2.27 KB

Usage

The page

Create a normal Filament importer, then a page that points at it:

use SolutionForest\FilamentImportWizard\Pages\ImportWizardPage;

class ImportContacts extends ImportWizardPage
{
    protected static ?string $importer = ContactImporter::class;
}

The title, navigation and authorization (canAccess(), shouldRegisterNavigation()) work like any Filament page.

Register it

With the plugin (recommended — gives per-panel settings):

use SolutionForest\FilamentImportWizard\ImportWizardPlugin;

$panel->plugin(
    ImportWizardPlugin::make()
        ->pages([ImportContacts::class])
        ->disk('s3')            // where uploads are stored
        ->chunkSize(1000),      // rows per queued job
);

…or just ->pages([ImportContacts::class]) for the defaults.

As a button (slide-over)

For a list page or table header use ImportWizardAction instead of a page — see Slide-over action.

Several panels

Register the plugin on each panel with its own settings. Settings come from the panel serving the request, uploads are kept under {directory}/{panel-id}/, and a path from another panel's directory is rejected. One page class can be shared.

// AdminPanelProvider
ImportWizardPlugin::make()->pages([ImportContacts::class])->audit()->chunkedUploads();
// StaffPanelProvider
ImportWizardPlugin::make()->pages([ImportContacts::class])->disk('staff')->requireApproval();

Page options

Override on your page class when one page needs something different:

Method Purpose
getUploadDisk() / getUploadDirectory() Where this page stores uploads
getChunkSize() Rows per queued job
getRowsPerReviewRequest() Rows validated per poll in Review
getRowChecks() File-level checks, e.g. duplicates — see Rules
getAcceptedFileTypes() Allowed MIME types
getEntityLabel() The word(s) in the page title — override to translate (Localization)

Every plugin and config option is listed in Configuration.

Faster imports

Add use ValidatesQuickly; to your importer to skip Laravel's validator for rows that certainly pass — same errors and messages, about 2× faster imports. See Performance.