Advanced

Artisan Commands

CLI commands for scaffolding importers and cleaning up old import data.

Tapix provides two Artisan commands: one for scaffolding new importers and one for cleaning up old import data.

make:tapix-importer

Generates a new importer class in app/Importers/.

Terminal
php artisan make:tapix-importer ContactImporter

The generated class extends BaseImporter with stub methods for model() and fields():

app/Importers/ContactImporter.php
namespace App\Importers;

use Tapix\Core\Fields\ImportField;
use Tapix\Core\Fields\ImportFieldCollection;
use Tapix\Core\Importing\BaseImporter;

final class ContactImporter extends BaseImporter
{
    public function model(): string
    {
        return \App\Models\Contact::class;
    }

    public function fields(): ImportFieldCollection
    {
        return ImportFieldCollection::make([
            ImportField::make('name')->required(),
        ]);
    }
}

tapix:cleanup

Removes old import records from the database. Runs two cleanup passes:

Terminal
php artisan tapix:cleanup

Completed and Failed Imports

Deletes imports with a status of Completed or Failed that are older than the specified number of days. Defaults to the cleanup_after_days config value (30 days).

Terminal
php artisan tapix:cleanup --days=60

Abandoned Imports

Deletes imports in non-terminal statuses (Uploading, Mapping, Reviewing, Previewing) that are older than the specified number of hours. Defaults to 24 hours.

Terminal
php artisan tapix:cleanup --hours=48

Scheduling

Run the cleanup command daily to keep the database tidy:

routes/console.php
Schedule::command('tapix:cleanup')->daily();
Schedule the cleanup command in routes/console.php to run daily. This prevents the tapix_imports and tapix_import_rows tables from growing indefinitely.

Failed Import Rows

The FailedImportRow model uses Laravel's MassPrunable trait. Failed rows older than the cleanup_after_days config value are automatically included in the prunable query. Clean them up with:

Terminal
php artisan model:prune

You can schedule this alongside the cleanup command:

routes/console.php
Schedule::command('tapix:cleanup')->daily();
Schedule::command('model:prune')->daily();
Copyright © 2026