PHPackages                             sextanet/laravel-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. [Database &amp; ORM](/categories/database)
4. /
5. sextanet/laravel-files

ActiveLibrary[Database &amp; ORM](/categories/database)

sextanet/laravel-files
======================

Connect real files with your models in Laravel 11+

1.1.2(7mo ago)12.7k—4.2%MITPHPPHP ^8.3|^8.4CI passing

Since Sep 28Pushed 6mo agoCompare

[ Source](https://github.com/sextanet/laravel-files)[ Packagist](https://packagist.org/packages/sextanet/laravel-files)[ Docs](https://github.com/sextanet/laravel-files)[ GitHub Sponsors](https://github.com/SextaNet)[ RSS](/packages/sextanet-laravel-files/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (12)Versions (8)Used By (0)

Laravel Files
=============

[](#laravel-files)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6e7432a515c881338faeeb14e80ad09f59364efd04c65e493d69459900e3f0e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73657874616e65742f6c61726176656c2d66696c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sextanet/laravel-files)[![GitHub Tests Action Status](https://camo.githubusercontent.com/312de25c773ec5b3881860e1ba6d312b994697ac90e8c090381935793fe89985/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73657874616e65742f6c61726176656c2d66696c65732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/sextanet/laravel-files/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/460fbfa488c7a8d09ea663b998a02136a43eb5816dbfae66b7781ed223133923/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73657874616e65742f6c61726176656c2d66696c65732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/sextanet/laravel-files/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/612423bfa8e4c235a4f73d84d2186f5b47690152ec6e8762b405d59366ddbbc5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73657874616e65742f6c61726176656c2d66696c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sextanet/laravel-files)

Upload seamless Storage and Database files in Laravel

It supports:

- [Native Laravel filesystems](https://laravel.com/docs/12.x/filesystem), such as `public`, `local`, `s3` disks
- [Local Temporary URLs ](https://laravel.com/docs/12.x/filesystem#enabling-local-temporary-urls)
- [Scoped disks](https://laravel.com/docs/12.x/filesystem#scoped-and-read-only-filesystems)

Requirements
------------

[](#requirements)

- Laravel 11+
- PHP 8.3+

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

[](#installation)

```
composer require sextanet/laravel-files
```

Publish and run the migrations with:

```
php artisan vendor:publish --tag="files-migrations"
php artisan migrate
```

Usage
-----

[](#usage)

```
use SextaNet\LaravelFiles\HasFiles; // 👈 1. Import

class YourModel extends Model
{
    use HasFiles; // 👈 2. Use it
}
```

We're ready! You can reuse it in each model, any times!

### Add (and Store)

[](#add-and-store)

```
$uploaded_file = request()->your_file; // let's supose you have "a_video.mp4"

$file = $user->addFile($uploaded_file); // using your default disk from config/filesystems.php
```

Passing a destination and name

```
$file = $user->addFile($uploaded_file, 'destination', 'my_file'); // will store on destination/my_file.mp4
```

### Get

[](#get)

You can get the `path`, `url` and `temporary_url` for each file

```
$path = $file->path();

$url = $file->url();

$temporary_url = $file->temporaryUrl();
```

### Get owner

[](#get-owner)

```
return $file->owner;
```

### Get all files

[](#get-all-files)

```
return $user->files;
```

### Get the latest file

[](#get-the-latest-file)

```
return $user->latestFile;
```

### Download

[](#download)

#### Without parameters

[](#without-parameters)

```
return $file->download();
```

#### With custom parameters

[](#with-custom-parameters)

```
$name = 'custom_name';
$headers = [];

return $file->download($name, $headers);
```

#### Turn off the extensions

[](#turn-off-the-extensions)

By default it preserves the extension. You can disable that by passing `preserveExtension` to `false`

```
return $file->download(preserveExtension: false);
```

#### Preserve original names

[](#preserve-original-names)

By default, it doesn't preserves original empty custom names.

Caution

If you enable that, you could overwrite your existent files.

```
LaravelFiles::preserveOriginalNames(true);
```

Advanced usage
--------------

[](#advanced-usage)

### Passing a type

[](#passing-a-type)

Type doesn't represent a real type or mimetype, it's only an optional field

```
$uploaded_file = request()->your_file;

// Store
$user->addFile($uploaded_file, type: 'document');

// Get
$user->files()->type('document')->get();
```

### Passing custom minutes in each implementation

[](#passing-custom-minutes-in-each-implementation)

```
$temporary_url = $file->getTemporaryUrl(20); // 20 minutes
```

Global usage
------------

[](#global-usage)

### Passing custom minutes globally

[](#passing-custom-minutes-globally)

```
// Don't forget to import the LaravelFiles facade
use SextaNet\LaravelFiles\Facades\LaravelFiles;

// Set temporary URL for 120 minutes
LaravelFiles::setTemporaryUrlMinutes(120);

$temporary_url = $file->getTemporaryUrl(); // Will return 120 minutes
```

### Passing a different disk in a specific instance

[](#passing-a-different-disk-in-a-specific-instance)

```
// Don't forget to import the LaravelFiles facade
use SextaNet\LaravelFiles\Facades\LaravelFiles;

// Store on another disk, like s3
LaravelFiles::setDisk('s3');
```

Custom keys
-----------

[](#custom-keys)

By default, we use the same `CURRENT_DISK` that you have in your `.env` file. If you want to force to use different values, you can add these keys with different values:

### Another disk

[](#another-disk)

```
FILES_DISK=s3
```

### Custom minutes

[](#custom-minutes)

```
FILES_TEMPORARY_URL_MINUTES=5
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

License
-------

[](#license)

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

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance65

Regular maintenance activity

Popularity23

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

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

Total

4

Last Release

215d ago

PHP version history (3 changes)1.0.0PHP ^8.4

1.1.1PHP ^8.3

1.1.2PHP ^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/5f00131e3e5dda3db4f1f0498fa677591bbd94d5c7087e24dcbd851cdecd9e84?d=identicon)[sextanet](/maintainers/sextanet)

---

Top Contributors

[![sebacarrasco93](https://avatars.githubusercontent.com/u/30738997?v=4)](https://github.com/sebacarrasco93 "sebacarrasco93 (81 commits)")

---

Tags

laraveleloquentfileslaravel-filesSextaNet

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sextanet-laravel-files/health.svg)

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

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spatie/laravel-model-flags

Add flags to Eloquent models

4301.1M1](/packages/spatie-laravel-model-flags)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17649.9k](/packages/lacodix-laravel-model-filter)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[indexzer0/eloquent-filtering

Powerful eloquent filtering

22425.9k3](/packages/indexzer0-eloquent-filtering)

PHPackages © 2026

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