dartika/laravel-uploadable-mutator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dartika/laravel-uploadable-mutator

Composer 安装命令:

composer require dartika/laravel-uploadable-mutator

包简介

Trait to upload files on setter (when submit file in forms) input

README 文档

README

Trait to upload files from inputs forms through mutator easily.

Installation

Include this in your composer.json:

{
    "require": {
        "dartika/laravel-uploadable-mutator": "dev-master"
    }
}

and then execute:

$ composer update

How to Use

In your model, add the Dartika\UploadableMutator\UploadableMutator trait:

use Dartika\UploadableMutator\UploadableMutator;

class Post extends Model {
    use UploadableMutator;
}

Now, add protected $fileFields array with all file fields ('input' => 'upload path') in your model:

protected $fileFields = [
    'image' => 'public/images',
    'pdf' => 'public/pdfs',
];

That's it!

When you save this fields, it will be uploaded automatically.

Example:

Post::create([
    'title' => 'Hello world'
    'image' => $request->image
]);

Notes

  • If you set a string instead of a file upload, it will be set without upload.
  • If empty input if sends, it will not be replace, it keep the old value.
  • To force empty field, you must create new function to overwritte it with $this->attributes['input'] = "";

Dártika Networks SL

统计信息

  • 总下载量: 59
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-07-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固