PHPackages                             azeemade/bulk-upload - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. azeemade/bulk-upload

ActiveLibrary

azeemade/bulk-upload
====================

Laravel Bulk Upload Package

1.0.2(3mo ago)09MITPHPPHP ^8.1

Since Dec 25Pushed 3mo agoCompare

[ Source](https://github.com/azeemade/bulk-upload)[ Packagist](https://packagist.org/packages/azeemade/bulk-upload)[ RSS](/packages/azeemade-bulk-upload/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (7)Used By (0)

Laravel Bulk Upload Package
===========================

[](#laravel-bulk-upload-package)

A powerful, fully customizable Laravel package for handling bulk uploads with ease. This package supports model-dependent validation, queue vs sync processing, multi-tenancy, and template generation.

Features
--------

[](#features)

- 🚀 **Sync &amp; Queue Support**: Automatically switches between synchronous and asynchronous processing based on configurable thresholds.
- 🛡️ **Robust Validation**: Row-by-row validation using standard Laravel rules defined in your Model.
- 🏢 **Multi-tenancy Ready**: Built-in support for multi-tenancy (tenant ID tracking) and user tracking.
- 📄 **Automatic Templates**: Generate CSV templates dynamically based on your Model's fillable attributes.
- ⚠️ **Error Handling**: Generates a detailed error CSV for failed rows, allowing users to correct and re-upload.
- 🧹 **Auto-Cleanup**: Automatically cleans up old files and temporary records.
- 📧 **Notifications**: Configurable email notifications upon upload completion.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require azeemade/bulk-upload
```

After installing, publish the configuration and migrations:

```
php artisan vendor:publish --provider="Azeemade\BulkUpload\BulkUploadServiceProvider"
```

Run the migrations:

```
php artisan migrate
```

Configuration
-------------

[](#configuration)

You can configure the package in `config/bulk-upload.php`. Key options include:

- `queue_threshold`: Number of rows to trigger background processing (Default: 500).
- `max_upload_size`: Maximum file size in KB (Default: 10MB).
- `notify_email`: Email address to receive upload completion notifications.
- `multitenancy.enabled`: Enable auto-capture of Tenant ID.
- `prune_after_days`: Days to keep failed upload files before cleanup.
- `error_format`: Format for error sheets (`csv` or `xlsx`, Default: `csv`).
- `model_map`: Map aliases to full class names (e.g., `'product' => \App\Models\Product::class`).

Usage
-----

[](#usage)

### 1. Prepare Your Model

[](#1-prepare-your-model)

Implement the `BulkUploadable` interface and use the `Uploadable` trait on any Eloquent model you want to support import for.

```
use Azeemade\BulkUpload\Contracts\BulkUploadable;
use Azeemade\BulkUpload\Concerns\Uploadable;
use Illuminate\Database\Eloquent\Model;

class Product extends Model implements BulkUploadable
{
    use Uploadable;

    protected $fillable = ['sku', 'name', 'price', 'stock'];

    /**
     * Define validation rules for a single row.
     */
    public function getUploadValidationRules(array $row): array
    {
        return [
            'sku' => 'required|unique:products,sku',
            'name' => 'required|string',
            'price' => 'required|numeric|min:0',
            'stock' => 'integer|min:0',
        ];
    }

    /**
     * Optional: Provide sample data for the template.
     */
    public function getTemplateSample(): array
    {
        return [
            'sku' => 'PROD-001',
            'name' => 'Sample Product',
            'price' => 10.50,
            'stock' => 100,
        ];
    }

    /**
     * Optional: Provide description/options for the template.
     */
    public function getTemplateOptions(): array
    {
        return [
            'sku' => 'Unique product code',
            'name' => 'Product Name',
            'price' => 'Decimal value',
            'stock' => 'Integer only',
        ];
    }

    /**
     * Process a single valid row.
     */
    public function processUploadRow(array $row): void
    {
        $this->create([
            'sku' => $row['sku'],
            'name' => $row['name'],
            'price' => $row['price'],
            'stock' => $row['stock'] ?? 0,
        ]);
    }
}
```

### 2. API Endpoints

[](#2-api-endpoints)

The package exposes standard API routes for handling uploads.

#### **Download Template**

[](#download-template)

Returns a CSV or Excel template based on the model's fillable fields.

```
GET /api/bulk-upload/template?model=App\Models\Product&format=xlsx
```

(Supported formats: `csv`, `xlsx`. Default: `csv`)

#### **Upload File**

[](#upload-file)

Upload a CSV or Excel file.

```
POST /api/bulk-upload/import
Content-Type: multipart/form-data

model: App\Models\Product
model: App\Models\Product
file: (binary)
metadata[source]: api       # Optional metadata
metadata[priority]: high
```

#### **Using Metadata in Model**

[](#using-metadata-in-model)

If you send metadata with the upload request, implement the `setBulkUploadMetadata` method in your model to receive it.

```
    /**
     * Receive metadata from the upload request.
     */
    public function setBulkUploadMetadata(array $metadata): void
    {
        if (isset($metadata['priority']) && $metadata['priority'] === 'high') {
            // Handle high priority logic
        }
    }
```

#### **Response:**

[](#response)

```
{
  "message": "Upload processed successfully",
  "data": {
    "batch_id": "9a1b2c...",
    "status": "processing",
    "total_rows": 1200
  }
}
```

#### **Check Status**

[](#check-status)

Poll this endpoint to get progress.

```
GET /api/bulk-upload/{batch_id}
```

**Response:**

```
{
  "data": {
    "id": 1,
    "batch_id": "9a1b2c...",
    "status": "completed",
    "processed_rows": 1200,
    "successful_rows": 1195,
    "failed_rows": 5,
    "user_id": 1,
    "tenant_id": null
  },
  "download_error_sheet_url": "http://domain.com/api/bulk-upload/9a1b2c.../errors"
}
```

### 3. Cleanup Task

[](#3-cleanup-task)

To ensure your storage doesn't fill up with old error sheets, add the cleanup command to your `app/Console/Kernel.php`:

```
$schedule->command('bulk-upload:cleanup')->daily();
```

### 4. Advanced: Using Custom Traits

[](#4-advanced-using-custom-traits)

The `Uploadable` trait provided by this package is optional. It simply provides default implementations for the interface methods.

If you prefer to organize your logic in your own Traits (e.g., `WorkerTrait`), **do not use** the `Azeemade\BulkUpload\Concerns\Uploadable` trait. Instead, just implement the `BulkUploadable` interface and define the methods in your own trait.

```
class Worker extends Model implements BulkUploadable
{
    use WorkerTrait; // Contains getUploadValidationRules, processUploadRow, etc.
}
```

### 5. Advanced: Custom Controller

[](#5-advanced-custom-controller)

You can use the `BulkUploadService` directly in your own controllers:

```
public function import(Request $request, \Azeemade\BulkUpload\Services\BulkUploadService $service)
{
    // Use alias from config or full class name
    $batch = $service->handle('product', $request->file('file'));

    return response()->json($batch);
}
```

Credits
-------

[](#credits)

- [Azeem](https://github.com/azeemade)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance80

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~20 days

Total

3

Last Release

103d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ee28acf17ba3bde023fb4623ed6124c96513ed03554d04359811e3a05085285d?d=identicon)[azeemade](/maintainers/azeemade)

---

Top Contributors

[![azeemade](https://avatars.githubusercontent.com/u/59115414?v=4)](https://github.com/azeemade "azeemade (11 commits)")

### Embed Badge

![Health badge](/badges/azeemade-bulk-upload/health.svg)

```
[![Health](https://phpackages.com/badges/azeemade-bulk-upload/health.svg)](https://phpackages.com/packages/azeemade-bulk-upload)
```

###  Alternatives

[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1225.0k10](/packages/fleetbase-core-api)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

116.6k](/packages/tomshaw-electricgrid)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
