Laravel Model File Uploader package

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 simple laravel package to handle multiple key based model route binding

Laravel Model UUID A simple package to handle the multiple key/column based route model binding for laravel package Installation Require the package u

A package for Laravel One Time Password (OTP) generator and validation without Eloquent Model, since it done by Cache.

Laravel OTP Introduction A package for Laravel One Time Password (OTP) generator and validation without Eloquent Model, since it done by Cache. The ca

A laravel package to handle cascade delete and restore on model relations.

Laravel Model Soft Cascade A laravel package to handle cascade delete and restore on model relations. This package not only handle the cascade delete

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

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

Laravel package to create autonumber for Eloquent model

Laravel AutoNumber Laravel package to create autonumber for Eloquent model Installation You can install the package via composer: composer require gid

This package provides a trait that will generate a unique uuid when saving any Eloquent model.

Generate slugs when saving Eloquent models This package provides a trait that will generate a unique uuid when saving any Eloquent model. $model = new

This package helps you to add user based follow system to your model.

Laravel Follow User follow unfollow system for Laravel. Related projects: Like: overtrue/laravel-like Favorite: overtrue/laravel-favorite Subscribe: o

Stapler-based file upload package for the Laravel framework.

laravel-stapler Laravel-Stapler is a Stapler-based file upload package for the Laravel framework. It provides a full set of Laravel commands, a migrat

Releases(1.1.0)
Owner
Emon Khan
Passionate developer with huge knowledge and ability to build dynamic web application using modern technology.
Emon Khan
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
A Laravel package that adds a simple image functionality to any Laravel model

Laraimage A Laravel package that adds a simple image functionality to any Laravel model Introduction Laraimage served four use cases when using images

Hussein Feras 52 Jul 17, 2022
Laravel comments - This package enables to easily associate comments to any Eloquent model in your Laravel application

Laravel comments - This package enables to easily associate comments to any Eloquent model in your Laravel application

Rubik 4 May 12, 2022
This Laravel package merges staudenmeir/eloquent-param-limit-fix and staudenmeir/laravel-adjacency-list to allow them being used in the same model.

This Laravel package merges staudenmeir/eloquent-param-limit-fix and staudenmeir/laravel-adjacency-list to allow them being used in the same model.

Jonas Staudenmeir 5 Jan 6, 2023
Sebuah aplikasi file hosting sederhana yang berguna untuk menyimpan berbagai file

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Willy Ferry 2 Nov 25, 2021
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
A laravel package to attach uuid to model classes

Laravel Model UUID A simple package to generate model uuid for laravel models Installation Require the package using composer: composer require touhid

null 10 Jan 20, 2022