PHPackages                             whilesmart/eloquent-files - 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. whilesmart/eloquent-files

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

whilesmart/eloquent-files
=========================

File upload and management package for Laravel applications

v1.0.0(4mo ago)0139[1 issues](https://github.com/whilesmartphp/eloquent-files/issues)2MITPHPPHP ^8.2

Since Feb 3Pushed 1mo agoCompare

[ Source](https://github.com/whilesmartphp/eloquent-files)[ Packagist](https://packagist.org/packages/whilesmart/eloquent-files)[ RSS](/packages/whilesmart-eloquent-files/feed)WikiDiscussions dev Synced 3w ago

READMEChangelog (1)Dependencies (7)Versions (5)Used By (2)

Eloquent Files
==============

[](#eloquent-files)

File upload and management package for Laravel applications.

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

[](#installation)

```
composer require whilesmart/eloquent-files
```

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

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag=files-config
```

### Configuration Options

[](#configuration-options)

```
return [
    'disk' => 'public',           // Storage disk
    'upload_path' => 'uploads',   // Base path for uploads
    'max_size' => 5120,           // Max file size in KB (5MB)
    'allowed_mimes' => 'image',   // Allowed mime types
    'register_routes' => true,    // Auto-register routes
    'route_prefix' => 'api',      // Route prefix
    'route_middleware' => ['api', 'auth:sanctum'],
];
```

Usage
-----

[](#usage)

### Adding Files to a Model

[](#adding-files-to-a-model)

Add the `HasFiles` trait to any model that should own files:

```
use Whilesmart\Files\Traits\HasFiles;

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

### API Endpoints

[](#api-endpoints)

When routes are registered, the following endpoints are available:

- `GET /api/files` - List files for authenticated user
- `POST /api/files` - Upload a file
- `GET /api/files/{id}` - Get file details
- `DELETE /api/files/{id}` - Delete a file

### Uploading Files

[](#uploading-files)

```
curl -X POST /api/files \
  -H "Authorization: Bearer {token}" \
  -F "file=@image.jpg"
```

### Response Format

[](#response-format)

```
{
  "success": true,
  "data": {
    "id": 1,
    "filename": "upload_abc123_1234567890.jpg",
    "original_name": "image.jpg",
    "url": "http://example.com/storage/uploads/1/upload_abc123.jpg",
    "mime_type": "image/jpeg",
    "size": 102400,
    "metadata": {
      "width": 1920,
      "height": 1080
    },
    "created_at": "2024-01-01T00:00:00Z"
  }
}
```

### Using the File Model Directly

[](#using-the-file-model-directly)

```
use Whilesmart\Files\Models\File;

// Get user's files
$files = File::ownedBy($user)->get();

// Delete a file (removes from storage and database)
$file->deleteFile();

// Check ownership
if ($file->isOwnedBy($user)) {
    // ...
}
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance84

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

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

Unknown

Total

1

Last Release

143d ago

### Community

Maintainers

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

---

Top Contributors

[![nfebe](https://avatars.githubusercontent.com/u/14317775?v=4)](https://github.com/nfebe "nfebe (1 commits)")

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/whilesmart-eloquent-files/health.svg)

```
[![Health](https://phpackages.com/badges/whilesmart-eloquent-files/health.svg)](https://phpackages.com/packages/whilesmart-eloquent-files)
```

###  Alternatives

[rahulhaque/laravel-filepond

Use FilePond the Laravel way

264127.9k2](/packages/rahulhaque-laravel-filepond)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135212.4k7](/packages/statamic-rad-pack-runway)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21313.7k3](/packages/ecotone-laravel)[slimani/filament-media-manager

A media manager plugin for Filament.

115.1k](/packages/slimani-filament-media-manager)

PHPackages © 2026

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