Artisan Commands
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/.
php artisan make:tapix-importer ContactImporter
The generated class extends BaseImporter with stub methods for model() and fields():
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:
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).
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.
php artisan tapix:cleanup --hours=48
Scheduling
Run the cleanup command daily to keep the database tidy:
Schedule::command('tapix:cleanup')->daily();
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:
php artisan model:prune
You can schedule this alongside the cleanup command:
Schedule::command('tapix:cleanup')->daily();
Schedule::command('model:prune')->daily();