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

Overview

Laravel Model File Uploader package

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

Install (Via Composer)

composer require plusemon/uploader

Usages

use HasUploader trait on the model



namespace App\Models;

...
use Plusemon\Uploader\HasUploader;

class User extends Authenticatable
{
    use ... HasUploader;
    ...
}

Upload files from the request input.

// single file
 $user->uploadRequestFile('user_avater')->saveInto('profile_picture');

You have uploaded you file into:

/public/uploads/users/images/users-1-avater.jpg

if you need update the model file again

 $user->uploadRequestFile('user_avater')->saveInto('profile_picture');

it will

  • delete the old file from the storage
  • upload the new file into the storage magically :)

Generate file url:

urlOf('avater')">">
 <img src="{{ $user->urlOf('avater')">

Delete a file:

 $user->deleteWith('avater');

it will delete the model with the model related file also :).

Multiple file upload:

 // multiple files
  $user->uploadRequestFiles('user_avater')->getUploadedFiles();
  // it will return you an array of uploaded file path.

Tip: if the file not exist on this dir or missing somehow then the noimage will show there.

urlOf('avater') ?? asset('assets/images/no-image-placeholder.png') }}">">
 <img src="{{ $user->urlOf('avater') ?? asset('assets/images/no-image-placeholder.png') }}">

Awesome right?

If you like my works please star my repo. Thanks.

You might also like...
A laravel package to handle model specific additional meta fields in an elegant way.

Laravel Meta Fields A php package for laravel framework to handle model meta data in a elegant way. Installation Require the package using composer: c

laravel-vat is a package that contains the Laravel related wiring code for ibericode/vat

laravel-vat is a package that contains the Laravel related wiring code for ibericode/vat, helping you deal with VAT legislation for businesses based in the EU.

A simple Laravel event log package for easy model based logging.

Karacraft Logman A simple Model Event Logging Package Usage Installation composer require karacraft/logman Migrate php artisan migrate Publish php a

Advance features / Topics related to Laravel

Laravel Advance Topics Notes Includes : v1.0.0 - Service Container v1.1.0 - View Composer v1.2.0 - Polymorphic Relationships v1.3.0 - Custom Facade Im

Eloquent model-caching made easy.
Eloquent model-caching made easy.

Model Caching for Laravel Supporting This Package This is an MIT-licensed open source project with its ongoing development made possible by the suppor

Geo-related tools PHP 7.3+ library built atop Geocoder and React libraries

Geotools Geotools is a PHP geo-related library, built atop Geocoder and React libraries. Features Batch geocode & reverse geocoding request(s) in seri

A multitool library offering access to recommended security related libraries, standardised implementations of security defences, and secure implementations of commonly performed tasks.

SecurityMultiTool A multitool library offering access to recommended security related libraries, standardised implementations of security defences, an

Keyword Generator Tool helps you discover keyword opportunities related to your query input.
Keyword Generator Tool helps you discover keyword opportunities related to your query input.

This plugin simply helps you discover keyword opportunities related to your query input. Installation Download the zip file of the repository or clone

Laravel Breadcrumbs - An easy way to add breadcrumbs to your @Laravel app.

Introduction Breadcrumbs display a list of links indicating the position of the current page in the whole site hierarchy. For example, breadcrumbs lik

Releases(1.1.0)
Owner
Emon Khan
Passionate developer with huge knowledge and ability to build dynamic web application using modern technology.
Emon Khan
This Package helps you in laravel application to log all desired activity for each request from request entry point to generate response at a single snapshot.

Laravel Scenario Logger This Package helps you in laravel application to log all desired activity for each request from request entry point to generat

Mehrdad Mahdian 6 Sep 27, 2021
Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be.

VatCalculator Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be. Integrates with Laravel and Cashier — or in a st

Dries Vints 1.1k Jan 5, 2023
Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be.

VatCalculator Handle all the hard stuff related to EU MOSS tax/vat regulations, the way it should be. Integrates with Laravel and Cashier — or in a st

Dries Vints 1.1k Jan 7, 2023
A Laravel package to upload large files

A Laravel package to upload large files

Payne 896 Dec 26, 2022
Laravel Logable is a simple way to log http request in your Laravel application.

Laravel Logable is a simple way to log http request in your Laravel application. Requirements php >= 7.4 Laravel version >= 6.0 Installation composer

Sagar 6 Aug 25, 2022
A laravel package to handle sanitize process of model data to create/update model records.

Laravel Model UUID A simple package to sanitize model data to create/update table records. Installation Require the package using composer: composer r

null 66 Sep 19, 2022
A laravel package to generate model hashid based on model id column.

Laravel Model Hashid A package to generate model hash id from the model auto increment id for laravel models Installation Require the package using co

Touhidur Rahman 13 Jan 20, 2022
A package to filter laravel model based on query params or retrieved model collection

Laravel Filterable A package to filter laravel model based on query params or retrived model collection. Installation Require/Install the package usin

Touhidur Rahman 17 Jan 20, 2022
Laravel-model-mapper - Map your model attributes to class properties with ease.

Laravel Model-Property Mapper This package provides functionality to map your model attributes to local class properties with the same names. The pack

Michael Rubel 15 Oct 29, 2022
Save Model is a Laravel package that allows you to save data in the database in a new way.

Save Model is a Laravel package that allows you to save data in the database in a new way. No need to worry about $guarded and $fillable properties in the model anymore. Just relax an use Save Model package.

Laratips 27 Mar 2, 2022