PHPackages                             hgacreative/storage-manager - 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. hgacreative/storage-manager

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

hgacreative/storage-manager
===========================

S3 Storage management

v1.2(5y ago)03072MITPHPPHP ^7.1.3

Since Nov 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/HGACreative/hga-storage-manager)[ Packagist](https://packagist.org/packages/hgacreative/storage-manager)[ Docs](https://digital.hgacreative.com/)[ RSS](/packages/hgacreative-storage-manager/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

HGA Storage Manager
===================

[](#hga-storage-manager)

Used for managing files on S3, via the storage manager facade you can easily upload and delete files as necessary.

This package records data into the database for operation.

**Install**

```
composer require hgacreative/storage-manager

```

**Migration**

```
php artisan vendor:publish

```

Look for Tag: storage-manager-migrations

```
php artisan migrate

```

**Import**

```
use HgaCreative\StorageManager\Facades\StorageManager;

```

**Upload file**

```
$file = StorageManager::uploadFile($file, $tag);

```

$tag is the directory you want to place it in, can be something like "users/avatars".

FileUpload model is returned if successful, else null is returned.

**Delete File**

```
StorageManager::deleteFile($key)

```

Deletes the file from the database and from S3

**Key**

The key is stored within the database, simply grab the one you want and use as such.

An example of a key: *directory/sub\_directory/image.jpg*

**Database**

The user\_id foreign key in the file\_uploads table assumes the users table id is defined as such :

```
class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            ...
            ...

```

If you're using bigIncrements, please change the package's migration foreign user\_id type to bigInteger.

**Extending FileUpload Model**

Create a FileUpload model within your Models folder and simply extend the package's model. You may now extend Its functionality.

```
