PHPackages                             angrydeer/attachfiles - 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. angrydeer/attachfiles

ActiveLibrary

angrydeer/attachfiles
=====================

Add some attached files to Eloquent model and store it to storage/app/attached/{Y-m-d} dir.

11.7k1PHP

Since Feb 18Pushed 10y ago1 watchersCompare

[ Source](https://github.com/AngryDeer/Attachfiles)[ Packagist](https://packagist.org/packages/angrydeer/attachfiles)[ RSS](/packages/angrydeer-attachfiles/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel 5.2 Attachfiles
=======================

[](#laravel-52-attachfiles)

[![Latest Version on Packagist](https://camo.githubusercontent.com/85949668fb3daa9f12bcef5c78f5657c60ae6d10e36b5f56fc6c183445fb716e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f416e677279446565722f41747461636866696c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/AngryDeer/Attachfiles)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/cfd9913ae3ecab1e7b53bcbfdd53dcbcb84e8db291d1abf0d25c98d5472d3f76/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f416e677279446565722f41747461636866696c65732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/AngryDeer/Attachfiles)[![Coverage Status](https://camo.githubusercontent.com/f30304a76ef3d9ad004ca4262a31af6133d1ca69ceefa9089722b9c081c92438/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f416e677279446565722f41747461636866696c65732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/AngryDeer/Attachfiles/code-structure)[![Quality Score](https://camo.githubusercontent.com/7b18958bf452991771785f171c1f9a7284fe7455ef08c36deca67e58c1064605/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f416e677279446565722f41747461636866696c65732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/AngryDeer/Attachfiles)[![Total Downloads](https://camo.githubusercontent.com/122182bb785ef5d1abc791958f5afadd0e966a435942b8624e8f8568920eec5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f416e677279446565722f41747461636866696c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/AngryDeer/Attachfiles)

Intro
-----

[](#intro)

Developed for easy work with the administration panel, such as Sleeping-Owl admin where all downloaded files are stored in a single folder and are not deleted if the record is not saved.

Attahfiles creates a link between a record of any model and a collection of downloaded files. He keeps them in the Storage assigning unique names, creates a new folder for each month, and day and deletes the originals from the shared folder upload.

When you remove attach, file is deleted from Storage.

You can add a file field Title, Alt, and Description. If the field Alt while maintaining empty, it is taken as the original file name.

Install
-------

[](#install)

Add to composer.json in require section:

```
"angrydeer/attachfiles": "dev-master"
```

Make composer update

after that add to config/app.php:

```
'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
         Angrydeer\Attachfiles\AttachfilesServiceProvider::class,
         // ...
     ],
```

console:

```
$ php artisan vendor:publish
$ php artisan migrate
```

Usage
-----

[](#usage)

In model:

```
// beginning omitted

use Angrydeer\Attachfiles\AttachableTrait;
use Angrydeer\Attachfiles\AttachableInterface;

class SomeModel extends Model implements AttachableInterface
{

   use AttachableTrait;

   public function myfunc()
   {

       $model = SomeModel::find(1);

       $model->updateOrNewAttach($filename, $title, $alt, $desc);

       $model->removeAttach($filename);

       $all_attach_files = $model->attaches;

       $filearray = [ 'file1', 'file12', 'file3' ]

       /*
       * as example, in $all_attach_files now attaches with  'file2', 'file3', 'file4'
       *
       */

       $model->keepOnly($filearray);
       $all_attach_files = $model->attaches;

       //  'file2', 'file3' included. file4 removed.

   }

}
```

in route.php you can write for images as example:

```
    Route::get('attaches/{date}/{filename}', function ($date,$filename) {
        return Storage::get('attaches/'.$date.'/'.$filename);
    });

```

in view:

```
        @foreach($model->attaches as $attach)

        @endforeach

```

Change log
----------

[](#change-log)

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

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

issues
------

[](#issues)

If you discover any related issues, please using the issue tracker.

Credits
-------

[](#credits)

- \[AngryDeer\]\[\]

License
-------

[](#license)

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

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5772e8dff984f15e440e5c58279baddf887f470a65da598846cb40d292568b4e?d=identicon)[Angrydeer](/maintainers/Angrydeer)

---

Top Contributors

[![AngryDeer](https://avatars.githubusercontent.com/u/16927102?v=4)](https://github.com/AngryDeer "AngryDeer (6 commits)")

### Embed Badge

![Health badge](/badges/angrydeer-attachfiles/health.svg)

```
[![Health](https://phpackages.com/badges/angrydeer-attachfiles/health.svg)](https://phpackages.com/packages/angrydeer-attachfiles)
```

PHPackages © 2026

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