DocumentController
extends BaseController
in package
Document Controller
This controller manages comprehensive document operations including document CRUD, file upload management, document categorization, and document information management. It provides functionality for managing documents with advanced filtering, search capabilities, and file handling for various document types including PDF, DOC, CSV, XLS, and PPT files.
Table of Contents
Methods
- __construct() : void
- Create a new DocumentController instance.
- create() : View
- Show the form for creating a new document.
- destroy() : RedirectResponse
- Remove the specified document from storage.
- edit() : View
- Show the form for editing the specified document.
- index() : View
- Display a listing of documents with search and pagination functionality.
- store() : RedirectResponse
- Store a newly created document in storage.
- update() : RedirectResponse
- Update the specified document in storage.
- uploadDoc() : string
- Upload and manage document files.
Methods
__construct()
Create a new DocumentController instance.
public
__construct() : void
Checks if user is logged in and has proper permissions for document management. Redirects to appropriate page if permissions are not met.
create()
Show the form for creating a new document.
public
create(Request $request) : View
Displays the document creation form with available document options, topics, and authors for assignment and configuration.
Parameters
- $request : Request
Return values
Viewdestroy()
Remove the specified document from storage.
public
destroy(int $id) : RedirectResponse
Deletes document record and associated files from storage. Handles file cleanup for both main document and SDS document files. Provides comprehensive file deletion with proper cleanup.
Parameters
- $id : int
Return values
RedirectResponseedit()
Show the form for editing the specified document.
public
edit(Request $request) : View
Displays the document edit form with security key validation. Requires valid security key to prevent unauthorized access. Loads comprehensive document data including options, topics, and authors.
Parameters
- $request : Request
Return values
Viewindex()
Display a listing of documents with search and pagination functionality.
public
index(Request $request) : View
Provides a paginated list of documents with search capabilities. Supports document name search with case-insensitive matching. Includes sorting functionality for better data organization.
Parameters
- $request : Request
Return values
Viewstore()
Store a newly created document in storage.
public
store(Request $request) : RedirectResponse
Validates document input, handles file upload, creates new document record, and manages document categorization. Supports comprehensive document data including file uploads, topic assignment, and author management.
Parameters
- $request : Request
Return values
RedirectResponseupdate()
Update the specified document in storage.
public
update(Request $request, int $id) : RedirectResponse
Handles document updates including file upload management, topic assignment, author management, and document categorization. Supports comprehensive document data updates with file handling and categorization.
Parameters
- $request : Request
- $id : int
Return values
RedirectResponseuploadDoc()
Upload and manage document files.
public
uploadDoc(mixed $doc, string $method[, mixed $extra = '' ][, string $uploadedDoc = '' ]) : string
Handles document file uploads with validation, file type checking, and secure file storage. Supports various document formats including PDF, DOC, DOCX, CSV, XLS, and PPT files. Manages file cleanup for update operations.
Parameters
- $doc : mixed
- $method : string
- $extra : mixed = ''
- $uploadedDoc : string = ''