An open API service indexing awesome lists of open source software.

https://github.com/plusemon/laravel-file-uploader

Easy way to upload Laravel model related files from the request.
https://github.com/plusemon/laravel-file-uploader

eloquent laravel laravel-package php upload

Last synced: 3 months ago
JSON representation

Easy way to upload Laravel model related files from the request.

Awesome Lists containing this project

README

          

## Laravel Model Easy File Uploader
Easy way to upload laravel model related file from the requset.

## Basic Examples

```php

$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
```bash
composer require plusemon/uploader
```

use HasUploader trait on the dedicated model

```php