haybea/laravel-trashcan 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

haybea/laravel-trashcan

最新稳定版本:v1.2.5

Composer 安装命令:

composer require haybea/laravel-trashcan

包简介

An observability & recovery console for Laravel soft-deleted records

README 文档

README

An observability & recovery console for Laravel soft-deleted records.

Laravel Trashcan provides a beautiful dashboard/console to manage your soft-deleted Eloquent records. Instead of digging through database tables or writing manual "Restore" logic, Trashcan gives you a central hub to visualize, restore, or permanently purge "trashed" data.

Features

  • Centralized Dashboard: View all models using the SoftDeletes trait in one place
  • Relationship Awareness: See which child records will be affected before you restore or purge a parent
  • Safe by Default: Automatically restricted to local environments, with a simple Gate for production access
  • Search & Filter: Filter by model type, deletion date, or search for specific IDs/attributes
  • Bulk Operations: Restore or permanently delete multiple items at once
  • Activity Logging: Track all restore and delete operations
  • Export Functionality: Export trashed records to CSV or JSON

Installation

You can install the package via Composer. After the package is installed, publish its assets and configuration file.

composer require haybea/laravel-trashcan

php artisan trashcan:install

Usage

Visit /trashcan in your browser to access the dashboard.

Registering Models

By default, Trashcan will attempt to find all models in your app/Models directory that use the SoftDeletes trait. If you have models in custom locations, you can define them in the config/trashcan.php file:

'only' => [
    App\Models\User::class,
    App\Models\Post::class,
    // Add your custom models here
],

Alternatively, you can exclude specific models:

'exclude' => [
    App\Models\SensitiveModel::class,
],

Configuration

Edit config/trashcan.php to customize Trashcan's behavior:

  • Middleware: Add custom middleware for authentication/authorization
  • Models: Configure which models to include/exclude
  • Columns: Customize which columns to display per model
  • Searchable: Define searchable columns per model
  • Logging: Enable/disable activity logging
  • Export: Configure export functionality

Authorization

By default, Trashcan only allows access in the local environment. To grant access in production, you should modify the gate method within your AppServiceProvider or create a custom service provider:

use Illuminate\Support\Facades\Gate;

/**
 * Register the Trashcan gate.
 *
 * This gate determines who can access Trashcan in non-local environments.
 */
protected function gate(): void
{
    Gate::define('viewTrashcan', function ($user) {
        return in_array($user->email, [
            'admin@yourdomain.com',
        ]);
    });
}

You can also configure per-model permissions in config/trashcan.php:

'model_permissions' => [
    App\Models\User::class => [
        'view' => 'viewTrashedUsers',
        'restore' => 'restoreUsers',
        'delete' => 'forceDeleteUsers',
    ],
],

License

MIT

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固