PHPackages                             codeflextech/laravel-uploader - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. codeflextech/laravel-uploader

ActiveLibrary[File &amp; Storage](/categories/file-storage)

codeflextech/laravel-uploader
=============================

Reusable Laravel uploader with DB tracking, polymorphic relations, S3 support &amp; optimization

3.0.0(1mo ago)118MITPHPPHP ^8.1

Since Jan 15Pushed 3w agoCompare

[ Source](https://github.com/faisalshah4004/laravel-uploader)[ Packagist](https://packagist.org/packages/codeflextech/laravel-uploader)[ RSS](/packages/codeflextech-laravel-uploader/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (3)Versions (6)Used By (0)

CodeFlexTech Laravel Uploader
=============================

[](#codeflextech-laravel-uploader)

A production-ready Laravel document uploader with:

- Polymorphic relations
- Public &amp; private Documents
- Local / S3 support
- Image optimization
- Auto cleanup on model delete
- **Multiple document Types Support**

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

[](#installation)

composer require codeflextech/laravel-uploader

```

## Configuration

Publish the config file to customize defaults:

```bash
php artisan vendor:publish --tag=uploader-config

```

### Key Config Options (`config/uploader.php`)

[](#key-config-options-configuploaderphp)

- **`table_name`**: The database table name (default: `documents`). Can be set via `UPLOAD_TABLE_NAME` env var.
- **`disk`**: Default storage disk (e.g., `public`, `s3`).
- **`folder`**: Default folder name inside the disk (default: `uploads`).
- **`structure`**: Date structure for organized Documents (default: `year/month/week`).
- **`visibility`**: documents visibility (`public` or `private`).
- **`optimize_images`**: Auto-resize images (boolean).

Direct Public Uploads
---------------------

[](#direct-public-uploads)

By default, Documents are stored in `storage/app/public` and symlinked. If you want to upload **directly** to the `public/` folder (bypassing `storage/`), you can define a custom disk.

1. Add to `config/filesystems.php`:

    ```
    'public_uploads' => [
        'driver' => 'local',
        'root'   => public_path('uploads'), // Uploads to public/uploads
        'url'    => env('APP_URL').'/uploads',
        'visibility' => 'public',
    ],
    ```
2. Use it in your upload:

    ```
    $user->upload($document, ['disk' => 'public_uploads']);
    ```

Basic Usage
-----------

[](#basic-usage)

### 1. Add Trait to Model

[](#1-add-trait-to-model)

Add the `HasDocuments` trait to any model that should have Documents attached (e.g., User, Post, Product).

```
use CodeFlexTech\Uploader\Traits\HasDocuments;

class User extends Authenticatable
{
    use HasDocuments;
}
```

### 2. Upload a Document

[](#2-upload-a-document)

Use the `DocumentUploader` facade or class to handle uploads.

```
$user->upload(
    $request->file('avatar'),
    [
        'folder' => 'avatars',
        'disk'   => 'public',
        'type'   => 'profile_pic'
    ]
);
```

Advanced Usage: Document Types &amp; Validation
-----------------------------------------------

[](#advanced-usage-document-types--validation)

You can categorize uploads by `type` (e.g., 'resume', 'profile\_pic').

### 1. Upload with Type

[](#1-upload-with-type)

Pass the `type` in the options array. If omitted, it defaults to `'document'`.

```
$user->upload($document, ['type' => 'resume']);
```

### 2. Replacing Documents

[](#2-replacing-documents)

By default, the `upload()` method enforces a 1-to-1 relationship per `type`. If a user already has a `'profile_pic'` and uploads a new one, the old document will automatically be deleted from storage and the database before the new one is saved.

### 3. Retrieve Documents by Type

[](#3-retrieve-documents-by-type)

The `HasDocuments` trait provides helper methods:

```
// Get all resumes
$resumes = $user->documentsByType('resume')->get();

// Get the latest profile picture
$pic = $user->latestFile('profile_pic');
```

License
-------

[](#license)

MIT

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance92

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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 ~34 days

Total

5

Last Release

30d ago

Major Versions

v1.0.0 → 2.0.02026-02-08

2.0.1 → 3.0.02026-06-03

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/125204538?v=4)[Muhammad Faisal Shah](/maintainers/faisalshah4004)[@faisalshah4004](https://github.com/faisalshah4004)

---

Top Contributors

[![faisalshah4004](https://avatars.githubusercontent.com/u/125204538?v=4)](https://github.com/faisalshah4004 "faisalshah4004 (8 commits)")

### Embed Badge

![Health badge](/badges/codeflextech-laravel-uploader/health.svg)

```
[![Health](https://phpackages.com/badges/codeflextech-laravel-uploader/health.svg)](https://phpackages.com/packages/codeflextech-laravel-uploader)
```

###  Alternatives

[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.5M85](/packages/unisharp-laravel-filemanager)[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[code16/sharp

Laravel Content Management Framework

79164.7k8](/packages/code16-sharp)[symfony/ux-cropperjs

Cropper.js integration for Symfony

19346.6k3](/packages/symfony-ux-cropperjs)[mmes-design/filament-file-manager

A beautiful file manager plugin for Filament. Browse, upload, rename, move and delete files with ease.

163.1k](/packages/mmes-design-filament-file-manager)[oxid-esales/media-library-module

Media library for OXID eShop

1676.6k4](/packages/oxid-esales-media-library-module)

PHPackages © 2026

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