Skip to content

[Feature] Soft Delete UI - Trash & Restore #9

@devalade

Description

@devalade

Description

When --soft-delete is used, generate a trash view with restore/permanently delete actions.

Current Behavior

--soft-delete adds SoftDeletes trait and migration column, but no UI for managing deleted records.

Expected Behavior

  • Add "Trash" tab/button on index page
  • Show deleted records with restore/force delete buttons
  • Add "Delete Permanently" vs "Move to Trash" distinction
  • Bulk restore and bulk force delete
  • Show deleted_at timestamp in trash view

Generated Code

class Index extends Component
{
    public string $view = 'active'; // 'active' | 'trash'
    
    public function getQuery()
    {
        $query = Product::query();
        
        if ($this->view === 'trash') {
            $query->onlyTrashed();
        }
        
        return $query->when($this->search, ...)
            ->orderBy($this->sortField, $this->sortDirection)
            ->paginate($this->perPage);
    }
    
    public function restore(int $id): void
    {
        Product::withTrashed()->find($id)->restore();
        session()->flash('success', 'Product restored.');
    }
    
    public function forceDelete(int $id): void
    {
        Product::withTrashed()->find($id)->forceDelete();
        session()->flash('success', 'Product permanently deleted.');
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions