celxkodez/laravel-model-file-manager

manage file upload on model fields

1.0.1 2022-12-29 07:26 UTC

This package is auto-updated.

Last update: 2024-04-29 04:45:43 UTC


README

Latest Version on Packagist Total Downloads Latest Unstable Version License PHP Version Require

A Laravel Package for handling file upload associated with model with ease

Installation

PHP 7.3+ and Composer are required.

To get the latest version of Laravel model file manager, simply require it

composer require celxkodez/laravel-model-file-manager

Or add the following line to the require block of your composer.json file.

"celxkodez/laravel-model-file-manager": "1.0.*"

You'll then need to run composer install or composer update to download it and have the autoloader updated.

Configuration

You can publish the configuration file using this command:

php artisan vendor:publish --provider="Celxkodez\LaravelModelFileManager\LaravelModelFileManagerServiceProvider"

A configuration-file named modelfilemanager.php with some sensible defaults will be placed in your config directory:

<?php

return [

    /**
     * Cloudinary Url
     *
     */
    'cloudinary_url' => getenv('CLOUDINARY_URL', ''),
];

Usage

On your Model, add the HasUploadField trait.

use Celxkodez\LaravelModelFileManager\Traits\HasUploadField;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use HasUploadField;
}

On Controller or anywhere with uploaded file

Post::create([
    ...
    'image' => request('file')
    ...
]);

Contributing

Please see CONTRIBUTING for details.

The Big “Thank You”!

Please Star the repo and share across your network. that would be so nice!

And also don't forget to follow me on twitter!

Thanks Again! Celestine Stephen.

License

The MIT License (MIT). Please see License File for more information.