定制 harman/filament-disk-cleanup 二次开发

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

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

harman/filament-disk-cleanup

最新稳定版本:v1.0.0

Composer 安装命令:

composer require harman/filament-disk-cleanup

包简介

Clean up the storage on model updates

README 文档

README

This package aims to automatically remove associated files from the storage when a model with an attachment is deleted or updated in Filament. By leveraging Laravel's built-in lifecycle hooks, it ensures that orphaned files are efficiently handled and removed from the disk, reducing disk space consumption and improving overall system performance.

Requirements

  • PHP 8.0+
  • Laravel 11+
  • Filament v3 or v4

Installation

You can install the package via composer:

composer require harman/filament-disk-cleanup

Usage

Use it in the model where you have an attachment. That's all.

It has two methods:

  • Cleanup::delete($model, 'columnName');
  • Cleanup::update($model, 'columnName');

For example : If you have an avatar column where you store the attachment in the User model, you can use it like this:

use Harman\FilamentDiskCleanup\Cleanup;
class User
{
//--
    protected static function booted()
    {
        static::deleted(function (User $user) {
            Cleanup::delete($user, 'avatar');
        });

        static::saved(function (User $user) {
            Cleanup::update($user, 'avatar');
        });
    }
//--
}

It automatically handles array of attachments. For example, if you have a files column where you store the multiple attachments in the Document model, you can use it like this:

use Harman\FilamentDiskCleanup\Cleanup;
class Document
{
//--
    protected static function booted()
    {
        static::deleted(function (Document $document) {
            Cleanup::delete($document, 'files');
        });

        static::saved(function (Document $document) {
            Cleanup::update($document, 'files');
        });
    }
//--
}

No extra configuration is required.

License

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

统计信息

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

GitHub 信息

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

其他信息

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