承接 codeflextech/laravel-uploader 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

codeflextech/laravel-uploader

Composer 安装命令:

composer require codeflextech/laravel-uploader

包简介

Reusable Laravel uploader with DB tracking, polymorphic relations, S3 support & optimization

README 文档

README

A production-ready Laravel document uploader with:

  • Polymorphic relations
  • Public & private Documents
  • Local / S3 support
  • Image optimization
  • Auto cleanup on model delete
  • Multiple document Types Support

Installation

composer require codeflextech/laravel-uploader


## Configuration

Publish the config file to customize defaults:

```bash
php artisan vendor:publish --tag=uploader-config

Key Config Options (config/uploader.php)

  • table_name: The database table name (default: documents). Can be set via UPLOAD_TABLE_NAME env var.
  • disk: Default storage disk (e.g., public, s3).
  • folder: Default folder name inside the disk (default: uploads).
  • structure: Date structure for organized Documents (default: year/month/week).
  • visibility: documents visibility (public or private).
  • optimize_images: Auto-resize images (boolean).

Direct Public Uploads

By default, Documents are stored in storage/app/public and symlinked. If you want to upload directly to the public/ folder (bypassing storage/), you can define a custom disk.

  1. Add to config/filesystems.php:

    'public_uploads' => [
        'driver' => 'local',
        'root'   => public_path('uploads'), // Uploads to public/uploads
        'url'    => env('APP_URL').'/uploads',
        'visibility' => 'public',
    ],
  2. Use it in your upload:

    $user->upload($document, ['disk' => 'public_uploads']);

Basic Usage

1. Add Trait to Model

Add the HasDocuments trait to any model that should have Documents attached (e.g., User, Post, Product).

use CodeFlexTech\Uploader\Traits\HasDocuments;

class User extends Authenticatable
{
    use HasDocuments;
}

2. Upload a Document

Use the DocumentUploader facade or class to handle uploads.

$user->upload(
    $request->file('avatar'),
    [
        'folder' => 'avatars',
        'disk'   => 'public',
        'type'   => 'profile_pic'
    ]
);

Advanced Usage: Document Types & Validation

You can categorize uploads by type (e.g., 'resume', 'profile_pic').

1. Upload with Type

Pass the type in the options array. If omitted, it defaults to 'document'.

$user->upload($document, ['type' => 'resume']);

2. Replacing Documents

By default, the upload() method enforces a 1-to-1 relationship per type. If a user already has a 'profile_pic' and uploads a new one, the old document will automatically be deleted from storage and the database before the new one is saved.

3. Retrieve Documents by Type

The HasDocuments trait provides helper methods:

// Get all resumes
$resumes = $user->documentsByType('resume')->get();

// Get the latest profile picture
$pic = $user->latestFile('profile_pic');

License

MIT

codeflextech/laravel-uploader 适用场景与选型建议

codeflextech/laravel-uploader 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 01 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 codeflextech/laravel-uploader 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 codeflextech/laravel-uploader 我们能提供哪些服务?
定制开发 / 二次开发

基于 codeflextech/laravel-uploader 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-15