mintellity/upload-document

1.1.0 2024-04-25 09:29 UTC

This package is auto-updated.

Last update: 2024-09-25 10:27:50 UTC


README

这是一个用于 Laravel,简化上传文档到任何模型的包。

安装

您可以通过 composer 安装此包。

composer require mintellity/upload-document

您可以选择发布资产、配置和迁移文件。

php artisan upload-document:install

可选:您还可以发布视图文件。

php artisan vendor:publish --tag="upload-document-views"

使用方法

将特性添加到任何需要包含文档的模型。

use Mintellity\UploadDocument\Traits\InteractsWithDocuments;

可选:您可以编辑配置文件。User 数组用于不同类型的文档。

return [
    'routes'         => [
        'middleware' => [
            'web'
        ]
    ],
    App\Models\User::class => [
        'first'  => 'First',
        'second' => 'Second',
        'third'  => 'Third',
    ]
];

在某些视图中添加组件表单来上传文档。

<x-upload-document-upload-form/>

组件有许多变量可以配置。

model - A model linked to documents.
model-label - A label for the models. Default value is 'Modelltyp'.
selected-model - If the specific model is already chosen.
collection-label - A label for the document types. Default value is 'Dateityp'.
allowedMimeTypes - An array of allowed document types. Default value is '.pdf',
multiple - Boolean value for allowing the users to upload multiple files. Default value is 'false'.

在某些视图中添加组件表来显示文档。

<x-document-table-document-table/>

组件也有可配置的变量。

documents - A collection from documents.
selected-model - If the specific model is already chosen.
edit - Boolean value for allowing the users to update or delete the documents. Default value is 'true'.

示例。

<x-document-table-document-table :model="User::class" :model-label="'Choose from the list'" :multiple="true"/>
<x-document-table-document-table :selected-model="User::first()" :collection-label="'Choose from the list'"/>

<x-document-table-document-table :documents="auth()->user()->getDocuments()"/>
<x-document-table-document-table :selected-model="User::first()" :edit="false"/>

更新日志

有关最近更改的更多信息,请参阅 更新日志

鸣谢

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件