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
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-01