# Estate Administration - Document Upload Guide

## Overview
Each estate case task now supports document uploads. Users can upload supporting documents for each step of the estate administration process.

## What Was Added

### 1. Database Field
- `EstateTask` model already has `document_path` field for storing uploaded documents

### 2. View Updates
**File**: `resources/views/admin/estate/show.blade.php`

Each task now displays:
- **Document Upload Section** with a light blue background
- **Current Document Display** (if already uploaded) with download link
- **File Upload Form** allowing PDF, DOC, DOCX, JPG, JPEG, PNG files (max 10MB)
- **Upload Button** to submit the document

### 3. Controller Method
**File**: `app/Http/Controllers/EstateController.php`

Added `uploadTaskDocument($caseId, $taskId)` method that:
- Validates the estate case exists
- Validates the task belongs to that case
- Validates the uploaded file (PDF, Word, or image formats, max 10MB)
- Deletes old document if exists
- Stores new document in `storage/app/estate-documents/` directory
- Auto-sets task status to "in_progress" when document is uploaded
- Returns success message

### 4. Route
**File**: `routes/web.php`

New route added:
```
POST /admin/estate/{caseId}/task/{taskId}/upload
Route name: admin.estate.task.upload
```

## How to Use

### Upload a Document:
1. Navigate to an estate case details page (`/admin/estate/{id}`)
2. Scroll to the task you want to upload a document for
3. In the "Supporting Document" section, click the file input
4. Select a document file (PDF, Word doc, or image)
5. Click the "Upload" button

### What Happens:
- Document is stored on the server
- Task status automatically changes to "In Progress"
- Download link appears for future access
- Success message confirms upload

## Document Storage
Documents are stored at: `storage/app/estate-documents/`

Files can be accessed via: `http://domain.com/storage/estate-documents/filename`

## File Requirements
- **Formats**: PDF, DOC, DOCX, JPG, JPEG, PNG
- **Max Size**: 10MB
- **Required**: Yes (at least when uploading)

## Task Categories with Documents
1. **Receive Death Certificate** - Upload certified death certificate
2. **Locate Original Will** - Upload found will or proof of location
3. **Apply for Probate** - Upload probate application forms and approvals
4. **Collect Assets** - Upload asset statements and collections
5. **Pay Debts** - Upload debt payment proof and statements
6. **Distribute to Beneficiaries** - Upload distribution receipts

## Error Handling
- If file is too large (>10MB), upload will fail with error message
- If file format not supported, upload will fail
- If task/case not found, 404 error displayed

## Future Enhancements
- Support for multiple documents per task
- Document versioning and history
- Document type categorization
- E-signature support
- Direct integration with government portals
