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

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

plusemon/uploader
=================

Laravel model file upload helper package.

1.1.0(3y ago)5281MITPHP

Since Jun 1Pushed 2y ago1 watchersCompare

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

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

Laravel Model Easy File Uploader
--------------------------------

[](#laravel-model-easy-file-uploader)

Easy way to upload laravel model related file from the requset.

Basic Examples
--------------

[](#basic-examples)

```
$product = Product::first();

// Store file
$product->uploadRequestFile('image'); // attach $request->image into $product->image
$product->uploadRequestFile('image', 'thumbnail'); // attach $request->image into $product->thumbnail
$product->uploadRequestFile('image')->saveInto('thumbnail'); // save into custom column

// Update file
$product->uploadRequestFile('image')->updateInto('thumbnail'); // will delete old file and update the new file

// Delete file
$product->deleteFile('image');
$product->deleteWithFile('image'); // delete the model with file
$product->deleteWith('image'); // deleteWithFile() shorter

// Upload multiple files
$product->uploadRequestFiles('images')->getUploadedFiles(); // return the uploaded files as array
$product->uploadRequestFiles('images')->saveInto('thumbnails', true); // save as array into $product->thumbnails
$product->uploadRequestFiles('images')->saveAsArrayInto('thumbnails');

# Note: all the files will be save into /public/uploads/products/images/products-1.jpg

// Get the attached file url
$product->urlOf('image') // https://website.com/uploads/products/images/products-1.jpg

// Render the file
//

## Advance

// Intervention Image support
$product->uploadRequestFile('image')->image()->resize()->crop()->save();

// custom file upload helper
$product->upload($request->file('image'), $module_name = 'products', $file_type = 'images', $unique_id = 123);
```

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

[](#installation)

```
composer require plusemon/uploader
```

use HasUploader trait on the dedicated model

```
