TerminalController
extends BaseController
in package
Terminal Management Controller
This controller handles all operations related to airport terminal management. It provides CRUD operations for managing terminal details, terminal images, terminal options, and associated airport data. The controller includes features for listing, creating, editing, viewing, and deleting terminal records with proper validation, image processing, and admin activity logging.
Features:
- DataTables integration with advanced search and filtering
- Image upload and processing with organized directory structure
- Terminal type management (terminal, concourse, gates)
- Terminal alias generation and slug management
- Map image handling (2D and 3D)
- Terminal level management with printable and interactive maps
- Security validation with MD5 hash verification
- Admin activity logging for all operations
- Drag and drop sorting for terminal levels
- File management with automatic cleanup
Tags
Table of Contents
Methods
- __construct() : void
- Constructor for TerminalController
- changeImageLevel() : bool
- Change terminal level name and update associated files
- changeLevelText() : bool
- Change terminal level text description
- create() : View
- Show the form for creating a new terminal resource
- deleteImage() : void
- Delete terminal level image
- deleteMapImage() : void
- Delete terminal map images (2D or 3D)
- destroy() : RedirectResponse
- Remove the specified terminal resource from storage
- edit() : View|RedirectResponse
- Show the form for editing the specified terminal resource
- index() : View|DataTable
- Display a listing of terminal resources
- saveLevelData() : bool
- Save terminal level data (name and text) in one operation
- show() : void
- Display the specified terminal resource
- sorting() : void
- Sort terminal level images via drag and drop
- store() : RedirectResponse
- Store a newly created terminal resource in storage
- terminalImage() : View|RedirectResponse
- Show terminal level management interface
- update() : RedirectResponse
- Update the specified terminal resource in storage
- upload() : JsonResponse
- Upload image for terminal content
- UploadImageToServer() : void
- Upload and process terminal level images
Methods
__construct()
Constructor for TerminalController
public
__construct() : void
Initializes the controller by checking user authentication and permissions. Redirects to login if user is not authenticated or lacks proper permissions.
changeImageLevel()
Change terminal level name and update associated files
public
changeImageLevel(Request $request, int $id) : bool
Updates the level name and renames associated image files (both printable and 3D images) to maintain consistency. Handles file system operations for both main images and preview thumbnails.
Parameters
- $request : Request
-
The HTTP request object containing new level name
- $id : int
-
The ID of the terminal image record
Tags
Return values
bool —Returns true on success, false on failure
changeLevelText()
Change terminal level text description
public
changeLevelText(Request $request, int $id) : bool
Updates the level text description for a terminal image record.
Parameters
- $request : Request
-
The HTTP request object containing new level text
- $id : int
-
The ID of the terminal image record
Tags
Return values
bool —Returns true on success, false on failure
create()
Show the form for creating a new terminal resource
public
create(Request $request) : View
Displays the create form with necessary data for adding a new terminal. Prepares dropdown lists for airports, terminal options, and other required fields.
Parameters
- $request : Request
-
The HTTP request object
Tags
Return values
View —Returns the create form view
deleteImage()
Delete terminal level image
public
deleteImage(Request $request, int $id) : void
Deletes a terminal level image record and removes associated files from storage. Handles cleanup of both main images and preview thumbnails for both printable and 3D images.
Parameters
- $request : Request
-
The HTTP request object containing form type
- $id : int
-
The ID of the terminal image record to delete
Tags
Return values
void —Outputs "true" on success or "false" on failure
deleteMapImage()
Delete terminal map images (2D or 3D)
public
deleteMapImage(int $id, Request $request) : void
Deletes either 2D or 3D map images for a terminal record and removes associated files from storage. Handles cleanup of both main images and preview thumbnails.
Parameters
- $id : int
-
The ID of the terminal record
- $request : Request
-
The HTTP request object containing image type
Tags
Return values
void —Outputs JSON response with success/failure status
destroy()
Remove the specified terminal resource from storage
public
destroy(int $id) : RedirectResponse
Deletes a terminal record and creates an admin activity log entry. Performs soft delete if the model supports it, otherwise performs hard delete.
Parameters
- $id : int
-
The ID of the terminal record to delete
Tags
Return values
RedirectResponse —Redirects to index with success message
edit()
Show the form for editing the specified terminal resource
public
edit(int $id, Request $request) : View|RedirectResponse
Displays the edit form for an existing terminal record with security validation. Includes MD5 hash verification to prevent unauthorized access and maintains pagination state and search filters in the form.
Parameters
- $id : int
-
The ID of the terminal record to edit
- $request : Request
-
The HTTP request object containing security key and pagination data
Tags
Return values
View|RedirectResponse —Returns edit form or redirects on security failure
index()
Display a listing of terminal resources
public
index(Request $request) : View|DataTable
This method handles both AJAX and regular requests for displaying terminal data. For AJAX requests, it returns DataTables formatted data with search and filtering capabilities. For regular requests, it returns a view with pagination and search filters.
Features:
- Pagination support with configurable page size
- Search filtering by terminal name, airport name, and airport code
- DataTables integration for enhanced user experience
- Action buttons for view, edit, and level management
- Case-insensitive search with ILIKE functions
- Role-based delete permissions (super admin only)
Parameters
- $request : Request
-
The HTTP request object containing search parameters and pagination data
Tags
Return values
View|DataTable —Returns view for regular requests or DataTable for AJAX
saveLevelData()
Save terminal level data (name and text) in one operation
public
saveLevelData(Request $request, int $id) : bool
Updates both the level name and level text for a terminal image record. Also renames associated image files to maintain consistency with the new level name. Handles file system operations for both main images and preview thumbnails.
Parameters
- $request : Request
-
The HTTP request object containing level name and text
- $id : int
-
The ID of the terminal image record
Tags
Return values
bool —Returns true on success, false on failure
show()
Display the specified terminal resource
public
show(int $id, Request $request) : void
Shows detailed information about a specific terminal record in HTML format. This method is typically called via AJAX to display data in a modal window. Only displays fields that have values (non-empty).
Parameters
- $id : int
-
The ID of the terminal record to display
- $request : Request
-
The HTTP request object
Tags
Return values
void —Outputs HTML content directly to the response
sorting()
Sort terminal level images via drag and drop
public
sorting(Request $request) : void
Handles the reordering of terminal level images based on drag and drop operations. Updates the sort_by field for all affected images.
Parameters
- $request : Request
-
The HTTP request object containing sortable data
Tags
Return values
void —Outputs JSON response with status
store()
Store a newly created terminal resource in storage
public
store(Request $request) : RedirectResponse
Validates and stores a new terminal record with comprehensive features:
- Validates required fields (airport_name, terminal_slug, terminal_type)
- Parses airport information from formatted string
- Generates terminal aliases based on type (terminal, concourse, gates)
- Handles map image uploads (2D and 3D) with organized directory structure
- Creates thumbnails using Intervention Image library
- Manages terminal sorting and alias generation
- Creates admin activity log entry
Parameters
- $request : Request
-
The HTTP request object containing form data and file uploads
Tags
Return values
RedirectResponse —Redirects to index with success message
terminalImage()
Show terminal level management interface
public
terminalImage(int $id, Request $request) : View|RedirectResponse
Displays the terminal level management interface for managing terminal images, levels, and interactive maps. Includes security validation with MD5 hash verification.
Parameters
- $id : int
-
The ID of the terminal record
- $request : Request
-
The HTTP request object containing security key and pagination data
Tags
Return values
View|RedirectResponse —Returns level management view or redirects on security failure
update()
Update the specified terminal resource in storage
public
update(Request $request, int $id) : RedirectResponse
Updates an existing terminal record with comprehensive features:
- Validates required fields
- Parses airport information from formatted string
- Handles map image replacement with old file cleanup
- Creates thumbnails using Intervention Image library
- Manages terminal aliases and type changes
- Creates admin activity log entry
- Maintains pagination and search filter state
Parameters
- $request : Request
-
The HTTP request object containing form data and file uploads
- $id : int
-
The ID of the terminal record to update
Tags
Return values
RedirectResponse —Redirects to index with success message and preserved filters
upload()
Upload image for terminal content
public
upload(Request $request) : JsonResponse
Handles image uploads for terminal content management, typically used with rich text editors. Supports various image formats and stores them in the public uploads directory.
Parameters
- $request : Request
-
The HTTP request object containing the image file
Tags
Return values
JsonResponse —Returns JSON response with file information
UploadImageToServer()
Upload and process terminal level images
public
UploadImageToServer(Request $request) : void
Handles the upload and processing of terminal level images including:
- Printable level images
- 3D interactive map images
- Automatic file naming and organization
- Thumbnail generation
- Database record creation
Supports multiple form types:
- add_terminal_photo: Creates new level with printable image
- add_3d_photo: Adds 3D image to existing level
- add_printable_photo: Updates printable image for existing level
Parameters
- $request : Request
-
The HTTP request object containing image file and form data
Tags
Return values
void —Outputs HTML content for image management interface