Giter Site home page Giter Site logo

dcat-form-media's Introduction

Dcat-admin 表单媒体拓展

预览

表单

form

动态表单

form-array

弹出选择框

form-modal

环境

  • PHP >= 7.2.5
  • Dcat-admin ^2.0

安装

composer 安装

composer require lake/form-media

安装扩展

开发工具->扩展 安装本扩展

使用

单图 数据库结构 varchar

可删除
$form->photo('photo','图片')
    ->nametype('datetime')
    ->remove(true)
    ->help('单图,可删除');
不可删除
$form->photo('photo','图片')
    ->path('pic') 
    ->nametype('uniqid') 
    ->remove(false)
    ->help('单图,不可删除');

$form->photo('photo','图片')
    ->nametype('uniqid') 
    ->help('单图,不可删除');

多图 数据库结构 json

$form->photos('photo', '图片')
    ->path('pic') 
    ->pageSize(16)
    ->nametype('uniqid') 
    ->limit(9)
    ->remove(true);  //可删除

视频 数据库结构 json/varchar

$form->video('video','视频')
    ->path('video') 
    ->nametype('uniqid') 
    ->remove(true);  //可删除

参数说明

path(string)    : 快速定位目录,默认为根目录
nametype(string): 文件重命名方式 uniqid|datetime,默认 uniqid
pageSize(int)   : 弹出层列表每页显示数量
limit(int)      : 限制条数
remove(boolean) :  是否有删除按钮

photo 、 photos 、 video 的参数默认值不一样

photo  默认 limit = 1  remove = false

photos 默认 limit = 9  remove = true

video  默认 limit = 1  remove = true
多图上传提交的数据为 json 字符串,如需输出数组,请在对应模型中加入下面代码
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Demo extends Model
{
    
    public function getPicturesAttribute($pictures)
    {

        return json_decode($pictures, true);

    }

}

特别鸣谢

感谢 yelphp 提供的原始代码

yelphp/narwhalformmedia

dcat-form-media's People

Contributors

ariel4100 avatar mikha-dev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.