定制 deepcube/handoff-image-upload 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

deepcube/handoff-image-upload

最新稳定版本:v1.0.2

Composer 安装命令:

composer require deepcube/handoff-image-upload

包简介

A powerful Filament component for image uploads with camera capture, QR code sharing, and temporary file management for Laravel applications

README 文档

README

Static Badge Static Badge

A Filament component for image uploads with support for camera, QR Code, and direct upload. Allows users to upload images directly from the current device or using a QR Code to upload from a mobile device.

Features

  • Filament Integration: Native component for Filament Forms
  • Multiple Upload Methods: Direct upload, camera capture, or via QR Code
  • Temporary Management: Automatic handling of temporary images
  • Multilingual: Support for customizable translations
  • Cleanup Command: Automatic command to clean temporary images

Installation

Install the package via Composer:

composer require deepcube/handoff-image-upload

Run the migrations:

php artisan migrate

Publish the configuration files (optional):

php artisan vendor:publish --tag="handoff-image-upload-config"

Publish the views (optional):

php artisan vendor:publish --tag="handoff-image-upload-views"

Filament Forms Integration

To use the component in a Filament form, add the field to your Form Schema:

use Deepcube\HandoffImageUpload\HandoffImageUpload;

public static function form(Form $form): Form
{
    return $form
        ->schema([
            HandoffImageUpload::make('profile_image')
                ->label('Profile Image'),
                
            HandoffImageUpload::make('document_scan')
                ->label('Document Scan'),
                
            // Other fields...
        ]);
}

Complete Resource Example:

<?php

namespace App\Filament\Resources;

use App\Models\User;
use Deepcube\HandoffImageUpload\HandoffImageUpload;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;

class UserResource extends Resource
{
    protected static ?string $model = User::class;
    
    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\TextInput::make('name')
                    ->label('Name')
                    ->required(),
                    
                Forms\Components\TextInput::make('email')
                    ->label('Email')
                    ->email()
                    ->required(),
                    
                HandoffImageUpload::make('avatar')
                    ->label('User Avatar'),
                    
                HandoffImageUpload::make('document')
                    ->label('Identity Document'),
            ]);
    }
    
    // ... rest of the Resource
}

Temporary Images Cleanup Command

The package includes a command to automatically clean temporary images:

Basic Usage

php artisan handoff-image:cleanup-temp

Available Options

# Delete files older than 48 hours
php artisan handoff-image:cleanup-temp --hours=48

# Dry-run mode (shows what would be deleted without actually deleting)
php artisan handoff-image:cleanup-temp --dry-run

# Combination of options
php artisan handoff-image:cleanup-temp --hours=12 --dry-run

Automation with Task Scheduler

Add the command to your app/Console/Kernel.php to run it automatically:

protected function schedule(Schedule $schedule)
{
    // Daily cleanup of temporary images older than 24 hours
    $schedule->command('handoff-image:cleanup-temp')
             ->daily()
             ->at('02:00');
             
    // Or every 6 hours
    $schedule->command('handoff-image:cleanup-temp --hours=6')
             ->everySixHours();
}

Translations

Publishing Translation Files

To customize translations, publish the language files:

php artisan vendor:publish --tag="handoff-image-upload-translations"

Translation files will be published to lang/vendor/handoff-image-upload/.

Translation Structure

The package includes translations for:

  • English (en/handoff-image-upload.php)
  • Italian (it/handoff-image-upload.php)

Adding New Languages

  1. Create a new folder for the language in lang/vendor/handoff-image-upload/:

    mkdir -p lang/vendor/handoff-image-upload/es
  2. Copy the English file as a base:

    cp lang/vendor/handoff-image-upload/en/handoff-image-upload.php \
       lang/vendor/handoff-image-upload/es/handoff-image-upload.php
  3. Translate the strings in the new file:

    <?php
    // lang/vendor/handoff-image-upload/es/handoff-image-upload.php
    return [
        'take_photo_instruction' => 'Toma una foto para subirla',
        'switch_camera' => 'Cambiar cámara',
        'take_photo' => 'Tomar foto',
        'retry' => 'Reintentar',
        'confirm' => 'Confirmar',
        // ... other translations
    ];

Customizing Existing Translations

After publishing the translations, you can modify the files in lang/vendor/handoff-image-upload/ to customize the messages according to your needs.

Usage

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-22